Import java. util. collection;
Import java. util. iterator;
Import com. soohuo. se. member. Ds. usercomment. appusercommentvo;
Import com. soohuo. se. Common. showgrade;
Import com. soohuo. Framework. genericexception;
Import java. util. arraylist;
/*
* @ Param count the total number of records
* @ Param URL the URL of the page to jump
* @ Param infosum the number of entries displayed per page
* @ Param Page Current page
* @ Param arr: arraylist for storing the result set
* @ Return: Result of Generation
* @ Throws genericexception
* For Oracle databases, use SQL statements to complete Paging
* The SQL statement format is:
* Select * from (select rownum num, column from table where... and... orderby...) Where num between start (from 1) and end
*/
Public class pagination {
// Set common parameters
Public void setparam (INT count, string URL, int infosum, int page)
{
If (page = 0 | PAGE
{
Page = 1;
}
This. Page = page;
This. url = URL + "& page = ";
This. infosum = infosum;
This. Count = count;
}
Public static int infosum = 3; // number of entries displayed on each page
Public static int COUNT = 0; // Total number of items
Public static string URL; // jump address
Public static int page; // the current page.
// Set the total number of pages
Public void setinfosum (INT infosum)
{
This. infosum = infosum;
}
// Obtain the total number of entries
Public int getcount ()
{
Return count;
}
// Obtain the number of entries displayed on each page
Public int getinfosum ()
{
Return infosum;
}
// Obtain the total number of pages
Public int getsumpage ()
{
Int pagesum = count/infosum;
If (count % infosum! = 0)
Pagesum + = 1;
Return pagesum;
}
// Set Js for redirection
Public String setjs ()
{
String JS = "";
Return JS;
}
// Set the page turning subject
Public String getpagebody (arraylist ARR) throws
Genericexception {
String STR = "";
Iterator it = arr. iterator ();
Showgrade = new showgrade ();
While (it. hasnext ())
{
Appusercommentvo Vo = (appusercommentvo) it. Next ();
STR + = showgrade. showusercommentgrade (VO. getcommentid () + "";
STR + ="
";
STR + ="Src = '/images/ping.gif'> issuer: ["+ VO. getuserid () +"]
";
// STR + ="Src = '/images/ping.gif'> issuer: ["+ VO. GetUserName () +"]
";
STR + ="
";
STR + ="
";
STR + ="Comments:
"+ VO. getcommentinfo () +"
";
STR + ="
";
}
This. Page = 0;
Return STR;
}
// Set the paging Header
Public String getpagehead ()
{
Int pagesum = This. getsumpage ();
String head = This. setjs () +"
A total of "+ pagesum +" pages are currently "+ Page +" pages ";
If (pagesum> 1 & page
{
Head + = "Jump
";For (INT I = 1; I{If (I = page ){Head + =""+ I +"";}Else {Head + =""+ I +"";}}Head + ="
";
}
Head + ="
";
Return head;
}
// Set the display at the end of the page flip
Public String getpagefoot (int pa)
{
Int pagesum = This. getsumpage ();
Int P = PA;
Int nextpage = 0; // next page
Nextpage = p + 1;
Int uppage = 0;
Uppage = p-1; // Previous Page
String foot ="
";
If (p> 1)
{
Foot + = "homepage & nbsp previous page ";
}
If (pagesum> 1 & P {
Foot + = "last page of the next page ";
}
Foot + ="
";
Return foot;
}
}