JSP Hibernate paging Code 1th/3 page _jsp programming

Source: Internet
Author: User
Visible use of Hibernate, in the query paging operation, is very flexible, hibernate will first attempt to use a specific database paging SQL, if no use, and then try to scrollable, if not, the final use of Rset.next () mobile approach.
(i) Pager class
* @ (#) Pager.java 2005-5-3
*
* Copyright (c), Jeffrey Hsu
*/
Package com.jeffrey.messagelove;
/**
* Pager holds the page info.
*/
public class Pager {
private int totalrows = 0; Total Records
private int totalpages = 0; Total pages
private int pageSize = 10; Display the number of data bars per page, default to 10 records
private int currentpage = 1; Current page
Private Boolean hasprevious = false; Whether there is a previous page
Private Boolean hasnext = false; Whether there is a next page
Public Pager () {
}
/**
* Initialize Pager
* @param totalrows Total record rows
* @param pageSize Total, hold by every page
*/
public void init (int totalrows, int pageSize) {
This.totalrows = totalrows;
This.pagesize = pageSize;
TotalPages = ((Totalrows + pageSize)-1)/pageSize;
Refresh (); Refresh current Page Information
}
/**
* @return Returns the currentpage.
*/
public int getcurrentpage () {
return currentpage;
}
/**
* @param currentpage Current page
*/
public void setcurrentpage (int currentpage) {
This.currentpage = CurrentPage;
Refresh ();
}
/**
* @return Returns the pageSize.
*/
public int getpagesize () {
return pageSize;
}
/**
* @param pageSize the pageSize to set.
*/
public void setpagesize (int pageSize) {
This.pagesize = pageSize;
Refresh ();
}
/**
* @return Returns the totalpages.
*/
public int gettotalpages () {
return totalpages;
}
/**
* @param totalpages the totalpages to set.
*/
public void settotalpages (int totalpages) {
This.totalpages = TotalPages;
Refresh ();
}
/**
* @return Returns the totalrows.
*/
public int gettotalrows () {
return totalrows;
}
/**
* @param totalrows the totalrows to set.
*/
public void settotalrows (int totalrows) {
This.totalrows = totalrows;
Refresh ();
}
Skip to First page
public void-A-I () {
CurrentPage = 1;
This.sethasprevious (FALSE);
Refresh ();
}
Get the previous page (reset the current page)
public void Previous () {
currentpage--;
Refresh ();
}
Get the next page
public void Next () {
System.out.println ("next:totalpages:" + totalpages +
"CurrentPage:" + currentpage);
if (CurrentPage < totalpages) {
currentpage++;
}
Refresh ();
}
Skip to last Page
public void Last () {
CurrentPage = TotalPages;
This.sethasnext (FALSE);
Refresh ();
}
public Boolean ishasnext () {
return hasnext;
}
/**
* @param hasnext the Hasnext to set.
*/
public void Sethasnext (Boolean hasnext) {
This.hasnext = Hasnext;
}
public Boolean ishasprevious () {
return hasprevious;
}
/**
* @param hasprevious the hasprevious to set.
*/
public void Sethasprevious (Boolean hasprevious) {
this.hasprevious = hasprevious;
}
Current 1/3 page 123 Next read the full text
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.