Paging class Sharing:
Package Com.hcj.util;import Java.util.arraylist;import Java.util.list;import org.apache.struts2.json.annotations.json;//page-type public class Page<e> {private int totals;//total number of queries private LIST&L T E> biglist; Total record set private list<e> smalllist; When the page displays the recordset private int currentpage = 1; Current page private int pages; Total pages private int pageSize = 8; Number of records per page private int privious; Prev private int Next; Next private Boolean firstpage = false;//First private Boolean lastpage = false; Last page public int gettotals () {return totals;} public void settotals (int totals) {this.totals = totals;} @JSON (serialize=false) public list<e> getbiglist () {return biglist;} public void Setbiglist (list<e> biglist) {this.biglist = biglist;} Public list<e> getsmalllist () {this.smalllist = new arraylist<e> (); for (int i = (currentPage-1) * pageSize; (I < currentpage* pageSize) && (i < totals); i++) {Smalllist.add (BigliSt.get (i)); } return smalllist;} public void Setsmalllist (list<e> smalllist) {this.smalllist = smalllist;} public int getcurrentpage () {return currentpage;} public void setcurrentpage (int currentpage) {this.currentpage = currentpage;} public int getpages () {if (totals% PageSize = = 0) {pages = totals/pagesize; } else {pages = totals/pagesize + 1; }return pages;} public void setpages (int pages) {this.pages = pages;} public int getpagesize () {return pageSize;} public void setpagesize (int pageSize) {this.pagesize = pageSize;} public int getprivious () {if (currentpage! = 1) {privious = currentPage-1; }else{privious = 1; }return privious;} public void setprivious (int privious) {this.privious = privious;} public int GetNext () {if (CurrentPage! = GetPages ()) {next = currentpage + 1; }else{next = currentpage; }return Next;} public void Setnext (int next) {This.next = next;} public Boolean isfirstpage () {if (currentpage == 1) {FirstPage = true; }return FirstPage;} public void Setfirstpage (Boolean firstpage) {this.firstpage = FirstPage;} public Boolean islastpage () {if (currentpage = = GetPages ()) {lastpage = true; }return LastPage;} public void Setlastpage (Boolean lastpage) {this.lastpage = LastPage;} Public page () {super ();//TODO auto-generated constructor stub}//input total results, current page and size per page (default is 8 pages) public page (list<e> biglist, int currentpage, int pageSize) {super (); this.biglist = Biglist;this.currentpage = Currentpage;this.pagesize = PA gesize;//set Total, this step is important this.settotals (Biglist.size ());} Public Page (list<e> biglist, int currentpage) {super (); this.biglist = Biglist;this.currentpage = CurrentPage; This.settotals (Biglist.size ());} }
Java Web Paging class sharing