posts - 165, comments - 198, trackbacks - 0, articles - 1
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理
          我先給出 jsp

          <%@?taglib?prefix="ec"?uri="/WEB-INF/extremecomponents.tld"?%>
          <%@?taglib?prefix="c"?uri="/WEB-INF/c.tld"?%>

          <%@?page?language??=??"java"???import="java.util.*"???pageEncoding="GBK"%>??

          <%@?taglib?uri="http://jakarta.apache.org/struts/tags-bean"?prefix="bean"%>?
          <%@?taglib?uri="http://jakarta.apache.org/struts/tags-html"?prefix="html"%>

          <head>
          <link???rel??="stylesheet"???type??="text/css"???href??="<c:url?value="/extremecomponents.css"??/>??">
          </head>

          ???
          <ec:table???
          ???????????
          items="table"??
          ???????????var
          ="result"??
          ???????????retrieveRowsCallback
          ="limit" ??? //關鍵 申明?
          ???????????action
          ="${pageContext.request.contextPath}/list.do"??
          ???????????imagePath
          ="${pageContext.request.contextPath}/images/table/*.gif"??
          ???????????title
          ="查詢結果"??
          ???????????width
          ="100%"??
          ???????????rowsDisplayed
          ="5"??
          ???????????
          >??
          ?????
          <ec:row>??
          ???????
          <ec:column?property="name"?/>
          ???????
          <ec:column?property="pass"?/>??
          ?????
          </ec:row>

          ???
          </ec:table>??

          提交給的Action
          ????public?ActionForward?execute(
          ????????ActionMapping?mapping,
          ????????ActionForm?form,
          ????????HttpServletRequest?request,
          ????????HttpServletResponse?response)?{
          ????????ListForm?listForm?
          =?(ListForm)?form;

          ????
          ????????Context?context?
          =?new?HttpServletRequestContext(request);??
          ????????LimitFactory?limitFactory?
          =?new?TableLimitFactory(context);??
          ????????TableLimit?limit?
          =?new?TableLimit(limitFactory);??
          ????????limit.setRowAttributes(Integer.MAX_VALUE,?
          5);???? //關鍵得出 extremecomponents? limit
          ????????
          ????????PageBean?page?
          =?new?PageBean();??
          ????????System.out.println(limit.getCurrentRowsDisplayed()
          +":limit");
          ????????
          ????????page.setPageSize(limit.getCurrentRowsDisplayed());?
          //ec通過limit對象傳遞pageSize給PageBean??
          ????????page.setPage(limit.getPage());//ec通過limit對象傳遞pageNo給PageBean??
          ????????
          ????????

          ????????request.setAttribute(
          "table",page.getList());
          ????????request.setAttribute(
          "totalRows",?new?Integer(page.getCount()));
          ????????
          ????????
          return?mapping.findForward("list");
          ????}

          提交 bean
          package?test;

          import?java.util.ArrayList;
          import?java.util.Hashtable;
          import?java.util.List;
          import?java.util.Map;

          ?
          public?class?PageBean?{??
          ?????
          ????????
          static?ArrayList?arr1?=?new?ArrayList();
          ????????
          static?{
          ????????????????
          for(int?i=0;i<1000;i++){
          ????????????????Map?map?
          =?new?Hashtable();
          ????????????????map.put(
          "name",i+"liukaiyi");
          ????????????????map.put(
          "pass",i+"123");
          ????????????????arr1.add(map);
          ????????????????}
          ????????}
          ??? ?? //仿照 數據 *************************************
          ?????
          ??????
          private?int?count?=?1000;?//?記錄總數??
          ??????private?int?pageSize?=?10;?//?每頁顯示記錄數??
          ??????????private?int?pageCount?=?0;?//?總頁數??
          ??????????private?int?page?=?1;?//?當前頁數??
          ?
          ???????????
          public?int?getCount()?{??
          ??????????????
          return?count;??
          ?????????}??
          ????????
          public?void?setCount(int?count)?{??
          ???????????
          if?(pageSize?!=?0)?{??
          ?????????????pageCount?
          =?count?/?pageSize;??
          ???????????
          if?(count?%?pageSize?!=?0)?{??
          ??????????????pageCount
          ++;??
          ????????????}??
          ???????}??
          ????????
          this.count?=?count;??
          ???????}??
          ????
          ??????
          public?int?getPage()?{??
          ?????????
          return?page;??
          ??????}??
          ??????
          public?void?setPage(int?page)?{??
          ????????
          this.page?=?page;??
          ?????}??
          ??????
          public?int?getPageCount()?{??
          ???????
          return?pageCount;??
          ?????}??
          ?????
          public?void?setPageCount(int?pageCount)?{??
          ????????
          this.pageCount?=?pageCount;??
          ?????}??
          ?????
          public?int?getPageSize()?{??
          ???????
          return?pageSize;??
          ??????}??
          ??????
          public?void?setPageSize(int?pageSize)?{??
          ????????
          this.pageSize?=?pageSize;??
          ??????}??
          ?
          ??????
          public?List?getList(){? ??? //提交 給 List 顯示的 數據********************
          ??????????
          int?st?=?(getPage()-1)*getPageSize()-1 ;
          ??????????
          int?end?=?st+getPageSize() +1;
          ??????????
          ??????????System.out.println(
          "bean?"+st+":"+end);
          ??????????List?arr?
          =?arr1.subList(st,end);
          ??????????
          return?arr?;?
          ??????}
          ??}?
          ?


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 昌吉市| 南昌市| 卓资县| 汕头市| 靖远县| 临夏县| 雅安市| 新平| 旌德县| 屏南县| 长武县| 台南市| 安新县| 巴林左旗| 绥阳县| 迁安市| 京山县| 石渠县| 贵南县| 习水县| 新津县| 陆丰市| 宝应县| 临西县| 龙陵县| 新余市| 靖宇县| 彩票| 东明县| 新巴尔虎左旗| 永平县| 江陵县| 河北区| 新河县| 延安市| 芜湖县| 乐业县| 托里县| 绥中县| 浦江县| 柘荣县|