General Patement class

xiaoxiao2021-03-06  72

/ * * CREATED ON 2004-10-20 * /

Import java.util.hashmap; import java.util.list; import java.util.map;

Import com.ibatis.common.util.paginatedAnd; Import com.ibatis.common.util.paginatedList;

/ ** * @Author Simon * General Points Page Class * * New Generation Page * // Condition is the map * map condition = new hashmap (); "Name", request.put ("name", request.getparameter) Name ")); * * // Get query results * List Raw = this.queryResult (); * * page Page = new page (raw, condition); * * Request.getSession () (). SetAttribute (" Page ", Page ); * Page page operation: * Page Page = Request.getSession (). GetaTtribute ("Page"); * // Jump mode * String param = request.getParameter ("param"); ​​* // Specified page * String Topage = Request.getParameter ("Pages"); * * if (String Param, String Topage) * Request.GetSession (). SetAttribute ("Page", Page); * * / public class page {

/ ** * record number * / private int totalsize = 0;

/ ** * All pages * / private int totalpage = 0;

/ ** * Current page * / private INT pageIndex = 0;

/ ** * Per page record number * / private int pageize = 8;

/ ** * Query result * / private list list = NULL;

/ ** * Query criteria * / private map condition = new hashmap ();

Public Page (List Raw, Map Condition) {THIS.CONDITION = CONDition;

IF (raw! = null) {paginatedlist list = new PaginatedArrayList (Raw, this.pageSize);

INT pageIndex = 0; int maxIndex = raw.size () / list.getpageSize ();

IF ((Raw.Size ()% list.getpagesize ())! = 0) {MAXINDEX ;}

List.gotopage (this.pageIndex); this.pageIndex = pageindex; this.totalpage = maxIndex; this.totalsize = raw.size ();

}} / ** * Turn page * * @Param param * @Param Topage * @return * / public boolean PageOperation (String Param, String Topage) {

IF (this.list! = null) {if (param.com) == 0) {if (Topage == Null) Return False; else {this.turnto (Integer.Parseint (Topage));} Else IF (param.com) == 0) {this.first ();} else if (param.com) == 0) {this.last ();} else IF Param.com == 0) {this.next ();} else if (param.com) == 0) {this.Prev ();} return true; } / ** * to the next page * / private void next () {paginatedlist list = (paginatedlist) this.list;

IF (list.isnextpageavailable ()) {list.nextpage (); this.pageIndex = list.getpageIndex ();}}

/ ** * forward one page * * / private void prev () {paginatedlist list = (paginatedlist) this.list;

IF (list.previouspageavailable ()) {list.previouspage (); this.pageIndex = list.getpageIndex ();}}

/ ** * Jump to the first page * / private void first () {this.pageIndex = 0; paginatedlist list = (paginatedList) this.list;

if (! list.isfirstpage ()) {list.gotopage (this.pageIndex);}}

/ ** * Jump to the last page * * / private void Last () {paginatedlist list = (paginatedlist) this.list;

if (! list.islastpage ()) {list.gotopage (this.totalpage); this.pageIndex = this.totalpage;}}

/ ** * Skip to the specified page * @Param Num * / private void Turnto (int Num) {paginatedlist list = (paginatedlist) this.list;

THIS.PAGEINDEX = NUM ​​- 1;

IF (this.pageindex <0) {this.pageIndex = 0;} else if (this.pageindex> this.totalpage) {this.pageIndex = this.totalpage;} list.gotopage (this.pageIndex);}

/ ** * @Return Returns the list. * / Public list getlist () {return list;}

/ ** * @Return Returns the pageindex. * / Public int getpageindex () {return pageindex;

/ ** * @Return Returns the Totalpage () {Return Totalpage;

/ ** * @Return Returns the Totalsize. * / Public int gettotalsize () {return totalsize;}

/ ** * @Return Returns the condition. * / Public map getcondition () {return

}

转载请注明原文地址:https://www.9cbs.com/read-89124.html

New Post(0)