eXtremeComponents 分页列表
生活随笔
收集整理的這篇文章主要介紹了
eXtremeComponents 分页列表
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
<%@taglib uri="/WEB-INF/extremecomponents" prefix="ec"%>
http://blog.csdn.net/hobbypei/article/details/6722488
說的非常詳細,自己寫下,備忘以后用
<form method="post" name="technicianFrm" action="<%= path%>/queryDeveloperList.action">
<div id="list_menu" >
<div class="nav1">
<div class="left">機構:<input name="" type="text" size="10" height="25" /> 關鍵字:<input name="" type="text" size="20" height="25"/>?</div>
<div class="right"><input name="serch" onClick=""type="image" src="<%=path %>/appstar/manage/images/serch2.png"><input name="and" onClick=""type="image" src="<%=path %>/appstar/manage/images/and.png">
</div>
</div>
</div>
<!-- sortable,filterable,rowsDisplayed 可以在extremetable.properties統一設置 -->
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<ec:table cellspacing="0" cellpadding="0" border="0"
action="${pageContext.request.contextPath}/queryDeveloperList.action"
items="allUserList"
var="arr"
imagePath="${pageContext.request.contextPath}/appstar/manage/images/table/*.gif"
width="100%" rowsDisplayed="10" form="technicianFrm"
sortable="true"
filterable="true"
>
<ec:exportCsv fileName="DepositHistory.csv" tooltip="CSV Download" />
<ec:exportXls fileName="listuser.xls" tooltip="Export Excel"/>
<ec:row>
<ec:column property="id" cell="rowCount" title="序號" />
<ec:column property="userId" title="userId"></ec:column>
<ec:column property="menuNo" title="MenuNo"></ec:column>
</ec:row>
</ec:table>
</td>
</tr>
</table>
</form>
如果數據量大,需要分頁,需要這個類
ExtremeTablePage
/**
* ExtremeTablePage.java
* com.zte.appstar.manage.util
*
* Function: TODO
*
* ver date author
* ──────────────────────────────────
* Aug 6, 2012 程仁銀
*
* Copyright (c) 2012, All Rights Reserved.
*/
package com.zte.appstar.manage.util;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.extremecomponents.table.context.Context;
import org.extremecomponents.table.context.HttpServletRequestContext;
import org.extremecomponents.table.limit.Limit;
import org.extremecomponents.table.limit.LimitFactory;
import org.extremecomponents.table.limit.Sort;
import org.extremecomponents.table.limit.TableLimit;
import org.extremecomponents.table.limit.TableLimitFactory;
/**
* ClassName:ExtremeTablePage
* Project:
* Company: ZTE
*
* @author 程仁銀
* @version
* @since Ver 1.1
* @Date Aug 6, 2012 11:30:08 AM
* @see
*/
@SuppressWarnings("unchecked")
public final class ExtremeTablePage {
/**
* 最大記錄數.
*/
public static final int MAX_PAGE_SIZE = 1000000000;
public static final int defaultPageSize = 10;
/**
* 工具類的私有構造方法.
*/
private ExtremeTablePage() {
}
/**
* 根據DEFAULT_PAGE_SIZE獲得數據.
*
* @param request 請求
* @return Limit 封裝的數據
*/
public static Limit getLimit(HttpServletRequest request) {
return getLimit(request, defaultPageSize);
}
/**
* 從request構造Limit對象實例.
* Limit的構造流程比較不合理,為了照顧export Excel時忽略信息分頁,導出全部數據
* 因此流程為程序先獲得total count, 再使用total count 構造Limit,再使用limit中的分頁數據查詢分頁數據
* 而SS的page函數是在同一步的,無法拆分,再考慮到首先獲得的totalCount
*
* @param request 請求
* @param defaultPageSize 頁面記錄數
* @return Limit 封裝的數據
*/
public static Limit getLimit(HttpServletRequest request,
int defaultPageSize) {
Context context = new HttpServletRequestContext(request);
LimitFactory limitFactory = new TableLimitFactory(context);
TableLimit limit = new TableLimit(limitFactory);
limit.setRowAttributes(MAX_PAGE_SIZE, defaultPageSize);
return limit;
}
/**
* 將Limit中的排序信息轉化為Map{columnName,升序/降序}.
* @param limit 封裝的頁面信息
* @return Map 排序信息
*/
public static Map getSort(Limit limit) {
Map sortMap = new HashMap();
if (limit != null) {
Sort sort = limit.getSort();
if ((sort != null) && sort.isSorted()) {
sortMap.put(sort.getProperty(), sort.getSortOrder());
}
}
return sortMap;
}}
public String queryDeveloperList()
{
System.out.println("############# queryDeveloperList #############");
Limit limit = ExtremeTablePage.getLimit(ServletActionContext.getRequest(),10);
System.out.println("limit = "+limit);
org.extremecomponents.table.limit.TableLimit@f7821d[rowStart=20,rowEnd=30,currentRowsDisplayed=10,page=3,totalRows=1000000000,exported=false,sort=org.extremecomponents.table.limit.Sort@17f7bf6[alias=<null>,property=<null>,sortOrder=<null>],filterSet=org.extremecomponents.table.limit.FilterSet@a37512[action=<null>]]
public String queryDeveloperList()
{
System.out.println("############# queryDeveloperList #############");
Limit limit = ExtremeTablePage.getLimit(ServletActionContext.getRequest(),10);
Sort sort = limit.getSort();
String columnSort = sort.getProperty();
System.out.println("limit = "+limit);
Map<String,Object> param1 = new HashMap<String,Object>();
param1.put("eq,userId", "superstar");
System.out.println("sort.getSortOrder() = "+sort.getSortOrder());
if(sort.getSortOrder()!=null){
param1.put("order,"+columnSort,sort.getSortOrder());
}
for(Filter f:limit.getFilterSet().getFilters())
{
System.out.println(f.getProperty()+" "+f.getValue());
param1.put("like,"+f.getProperty(),f.getValue());
}
List<UserPowerT> countList1 = this.userManageService.getObjListByParameter(UserPowerT.class, param1);
Map<String,Object> param2 = new HashMap<String,Object>();
param2.put("eq,userId", "superstar");
if(sort.getSortOrder()!=null){
param2.put("order,"+columnSort,sort.getSortOrder());
}
for(Filter f:limit.getFilterSet().getFilters())
{
System.out.println(f.getProperty()+" "+f.getValue());
param2.put("like,"+f.getProperty(),f.getValue());
}
List<UserPowerT> countList2 = this.userManageService.getListByPage(UserPowerT.class, param2,(limit.getPage()-1)*limit.getCurrentRowsDisplayed(),limit.getCurrentRowsDisplayed());
/*List<UserPowerT> allUserList = this.userManageService.queryUserListDemo(limit.getPage(),limit.getCurrentRowsDisplayed(),"superstar",columnSort,sortOrder);*/
ServletActionContext.getRequest().setAttribute("allUserList",countList2);
ServletActionContext.getRequest().setAttribute("totalRows",countList1.size());
return SUCCESS;
}
http://blog.csdn.net/hobbypei/article/details/6722488
說的非常詳細,自己寫下,備忘以后用
<form method="post" name="technicianFrm" action="<%= path%>/queryDeveloperList.action">
<div id="list_menu" >
<div class="nav1">
<div class="left">機構:<input name="" type="text" size="10" height="25" /> 關鍵字:<input name="" type="text" size="20" height="25"/>?</div>
<div class="right"><input name="serch" onClick=""type="image" src="<%=path %>/appstar/manage/images/serch2.png"><input name="and" onClick=""type="image" src="<%=path %>/appstar/manage/images/and.png">
</div>
</div>
</div>
<!-- sortable,filterable,rowsDisplayed 可以在extremetable.properties統一設置 -->
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<ec:table cellspacing="0" cellpadding="0" border="0"
action="${pageContext.request.contextPath}/queryDeveloperList.action"
items="allUserList"
var="arr"
imagePath="${pageContext.request.contextPath}/appstar/manage/images/table/*.gif"
width="100%" rowsDisplayed="10" form="technicianFrm"
sortable="true"
filterable="true"
>
<ec:exportCsv fileName="DepositHistory.csv" tooltip="CSV Download" />
<ec:exportXls fileName="listuser.xls" tooltip="Export Excel"/>
<ec:row>
<ec:column property="id" cell="rowCount" title="序號" />
<ec:column property="userId" title="userId"></ec:column>
<ec:column property="menuNo" title="MenuNo"></ec:column>
</ec:row>
</ec:table>
</td>
</tr>
</table>
</form>
如果數據量大,需要分頁,需要這個類
ExtremeTablePage
/**
* ExtremeTablePage.java
* com.zte.appstar.manage.util
*
* Function: TODO
*
* ver date author
* ──────────────────────────────────
* Aug 6, 2012 程仁銀
*
* Copyright (c) 2012, All Rights Reserved.
*/
package com.zte.appstar.manage.util;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.extremecomponents.table.context.Context;
import org.extremecomponents.table.context.HttpServletRequestContext;
import org.extremecomponents.table.limit.Limit;
import org.extremecomponents.table.limit.LimitFactory;
import org.extremecomponents.table.limit.Sort;
import org.extremecomponents.table.limit.TableLimit;
import org.extremecomponents.table.limit.TableLimitFactory;
/**
* ClassName:ExtremeTablePage
* Project:
* Company: ZTE
*
* @author 程仁銀
* @version
* @since Ver 1.1
* @Date Aug 6, 2012 11:30:08 AM
* @see
*/
@SuppressWarnings("unchecked")
public final class ExtremeTablePage {
/**
* 最大記錄數.
*/
public static final int MAX_PAGE_SIZE = 1000000000;
public static final int defaultPageSize = 10;
/**
* 工具類的私有構造方法.
*/
private ExtremeTablePage() {
}
/**
* 根據DEFAULT_PAGE_SIZE獲得數據.
*
* @param request 請求
* @return Limit 封裝的數據
*/
public static Limit getLimit(HttpServletRequest request) {
return getLimit(request, defaultPageSize);
}
/**
* 從request構造Limit對象實例.
* Limit的構造流程比較不合理,為了照顧export Excel時忽略信息分頁,導出全部數據
* 因此流程為程序先獲得total count, 再使用total count 構造Limit,再使用limit中的分頁數據查詢分頁數據
* 而SS的page函數是在同一步的,無法拆分,再考慮到首先獲得的totalCount
*
* @param request 請求
* @param defaultPageSize 頁面記錄數
* @return Limit 封裝的數據
*/
public static Limit getLimit(HttpServletRequest request,
int defaultPageSize) {
Context context = new HttpServletRequestContext(request);
LimitFactory limitFactory = new TableLimitFactory(context);
TableLimit limit = new TableLimit(limitFactory);
limit.setRowAttributes(MAX_PAGE_SIZE, defaultPageSize);
return limit;
}
/**
* 將Limit中的排序信息轉化為Map{columnName,升序/降序}.
* @param limit 封裝的頁面信息
* @return Map 排序信息
*/
public static Map getSort(Limit limit) {
Map sortMap = new HashMap();
if (limit != null) {
Sort sort = limit.getSort();
if ((sort != null) && sort.isSorted()) {
sortMap.put(sort.getProperty(), sort.getSortOrder());
}
}
return sortMap;
}}
public String queryDeveloperList()
{
System.out.println("############# queryDeveloperList #############");
Limit limit = ExtremeTablePage.getLimit(ServletActionContext.getRequest(),10);
System.out.println("limit = "+limit);
org.extremecomponents.table.limit.TableLimit@f7821d[rowStart=20,rowEnd=30,currentRowsDisplayed=10,page=3,totalRows=1000000000,exported=false,sort=org.extremecomponents.table.limit.Sort@17f7bf6[alias=<null>,property=<null>,sortOrder=<null>],filterSet=org.extremecomponents.table.limit.FilterSet@a37512[action=<null>]]
public String queryDeveloperList()
{
System.out.println("############# queryDeveloperList #############");
Limit limit = ExtremeTablePage.getLimit(ServletActionContext.getRequest(),10);
Sort sort = limit.getSort();
String columnSort = sort.getProperty();
System.out.println("limit = "+limit);
Map<String,Object> param1 = new HashMap<String,Object>();
param1.put("eq,userId", "superstar");
System.out.println("sort.getSortOrder() = "+sort.getSortOrder());
if(sort.getSortOrder()!=null){
param1.put("order,"+columnSort,sort.getSortOrder());
}
for(Filter f:limit.getFilterSet().getFilters())
{
System.out.println(f.getProperty()+" "+f.getValue());
param1.put("like,"+f.getProperty(),f.getValue());
}
List<UserPowerT> countList1 = this.userManageService.getObjListByParameter(UserPowerT.class, param1);
Map<String,Object> param2 = new HashMap<String,Object>();
param2.put("eq,userId", "superstar");
if(sort.getSortOrder()!=null){
param2.put("order,"+columnSort,sort.getSortOrder());
}
for(Filter f:limit.getFilterSet().getFilters())
{
System.out.println(f.getProperty()+" "+f.getValue());
param2.put("like,"+f.getProperty(),f.getValue());
}
List<UserPowerT> countList2 = this.userManageService.getListByPage(UserPowerT.class, param2,(limit.getPage()-1)*limit.getCurrentRowsDisplayed(),limit.getCurrentRowsDisplayed());
/*List<UserPowerT> allUserList = this.userManageService.queryUserListDemo(limit.getPage(),limit.getCurrentRowsDisplayed(),"superstar",columnSort,sortOrder);*/
ServletActionContext.getRequest().setAttribute("allUserList",countList2);
ServletActionContext.getRequest().setAttribute("totalRows",countList1.size());
return SUCCESS;
}
總結
以上是生活随笔為你收集整理的eXtremeComponents 分页列表的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 粉笔计算机基础知识,计算机基础知识2-实
- 下一篇: JDK卸载