A general JSP paging pagebean_jsp programming

Source: Internet
Author: User
Package com.shaccp.web.util;
Import java.util.List;
public class Pagebean {
/**
*
*
* @author ppy 2008-10-18 14:3:56
* Total Records of totalrecords
* List to save paging data
* PageNo Current Page
* PageSize Page size
* Query saves a string of user queries
* Pageaction Action-Paging servlet or action (struts)
* Method (the method of action in struts)
*
*
*/
private int totalrecords;
Private list List;
private int pageno;
private int pageSize;
Private String query;
Private String pageaction;
Private String method;
public void Setpageaction (String pageaction) {
This.pageaction = pageaction;
}
public void Setmethod (String method) {
This.method = method;
}
Public List getlist () {
return list;
}
public void setlist (list list) {
This.list = list;
}
public int Getpageno () {
return pageno;
}
public void Setpageno (int pageno) {
This.pageno = PageNo;
}
public int getpagesize () {
return pageSize;
}
public void setpagesize (int pageSize) {
This.pagesize = pageSize;
}
public int gettotalrecords () {
return totalrecords;
}
public void settotalrecords (int totalrecords) {
This.totalrecords = totalrecords;
}
public void Setquery (String query) {
this.query = query;
}
/**
* method to get total pages
* totalrecords%pagesize==0? (totalrecords/pagesize):(totalrecords/pagesize+1)
*
* @return
*/
public int gettotalpages () {
Return (totalrecords + pageSize-1)/pageSize;
}
/**
* Get Home
*
* @return
*/
public int gettoppage () {
return 1;
}
/**
* Get a previous page
*
* @return
*/
public int Getpreviouspageno () {
if (PageNo <= 1)
return 1;
Else
return (PAGENO-1);
}
/**
* Get the next page
*
* @return
*/
public int Getnextpageno () {
if (PageNo >= gettotalpages ()) {
return gettotalpages () = = 0? 1:gettotalpages ();
} else {
return PageNo + 1;
}
}
/**
* Get Last
*
* @return
*/
public int Getbottompageno () {
return gettotalrecords () = = 0? 1:gettotalpages ();
}
How to link page paging navigation one
Public String getPageToolBar1 () {
String str = "";
STR + + "<a href= '" + pageaction + "? method=" + Method + "&userquery="
+ query + "&pageno=" + getpreviouspageno () + "&pagesize="
+ pageSize + "' > Prev </a>";
STR + + "<a href= '" + pageaction + "? method=" + Method + "&userquery="
+ query + "&pageno=" + getnextpageno () + "&pagesize="
+ pageSize + "' > next page </a>";
return str;
}
How to link page paging navigation two
Public String getPageToolBar2 () {
String str = "";
int pagesplit = (PAGENO/5) * 5;
for (int i = PageSplit-1 I < (pagesplit + 6); i++) {
if (I <= 0) {
else if (PageNo = i) {
STR + + i + "";
else if (i > Gettotalpages ()) {
} else {
STR + + "<a href= '" + pageaction + "? Method=" + Method
+ "&userquery=" + query + "&pageno=" + i + "&pagesize="
+ pageSize + "' >" + i + "</a>" + "";
}
}
return str;
}
}
Related Article

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.