Paging class written in Java (for Users)

Source: Internet
Author: User
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;
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.