夢幻之旅

          DEBUG - 天道酬勤

             :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            671 隨筆 :: 6 文章 :: 256 評論 :: 0 Trackbacks
           2010寫的一個jsp分頁標簽, 基本能實現任何效果分頁(如谷歌, 百度分頁, AJAX分頁等), 并且能保存查詢參數, 自認為比較強大, 下面記錄使用方法:
           先上一個效果:
           

          1. pagebar.jar加入lib

          2. action里代碼(最少只需要加入3行代碼):
          IConditionHelper helper = ConditionHelper.getInstance(ServletActionContext.getRequest());
                      
                      UserLstReq userLstReq 
          = new UserLstReq();
                      userLstReq.setUserName(userName);
                      userLstReq.setBeginIndex(helper.getBeginIndex());
                      userLstReq.setPageSize(helper.getPageSize());
                      
                      helper.getCondition(userLstReq, UserLstReq.
          class);
                      
                      
                      UserLstRes res 
          = userService.queryUsers(userLstReq);
                      HttpServletRequest request 
          = ServletActionContext.getRequest();
                      request.setAttribute(
          "list", res.getResultLst());
                      request.setAttribute(
          "page"new BasePageBarBean(helper, res.getCount()));
             

          3. jsp代碼(最好是寫在一jsp里, 再include方便更改)
             <%@ taglib uri="http://www.huiwanpeng.com" prefix="p"%>
             
          <p:pagebar totalRowCount="${page.totalRowCount}" action="${page.action}" pageSize="${page.pageSize}" currentPageNum="${page.currentPageNum}" disableCss="color:green">
           總行數#totalRowCount#   
          |  
           總頁數#totalPageCount#  
          |
           當前第#currentPageNum#頁  
          |
           每頁數#pageSize# 
          | 
           
          <a onclick="#callFirstPageFun#">第一頁</a>| 
           
          <a onclick="#callForePageFun#"  style="#forePageDisableCss#">上一頁</a>|
           
          <a onclick="#callNextPageFun#" style="#nextPageDisableCss#">下一頁</a> | 
           
          <a onclick="#callLastPageFun#">最后頁</a> 
           
          <p:loop positiveStep="2" negativeStep="4" isFill="true" currentPageCss="color:red">
            
          <a style="#currentPageCss#" onclick="#callLoopPageFun#">#currentPageNum# </a>
           
          </p:loop>
           
          <input id="#inputPageNumId#" type="text" style="width:20px"/><input type="button" value="go" onclick="#callGoFun#"/>
             
          </p:pagebar>

          posted on 2014-06-20 11:53 HUIKK 閱讀(445) 評論(0)  編輯  收藏 所屬分類: Java
          主站蜘蛛池模板: 内乡县| 得荣县| 峨眉山市| 阳谷县| 桓台县| 聂拉木县| 韩城市| 桃江县| 安岳县| 师宗县| 安新县| 吉安市| 平度市| 信丰县| 辉南县| 阿鲁科尔沁旗| 谢通门县| 德钦县| 北京市| 疏附县| 油尖旺区| 华池县| 黔江区| 泰宁县| 南和县| 宝兴县| 文水县| 呈贡县| 如皋市| 横山县| 磐安县| 六枝特区| 大宁县| 南丹县| 综艺| 鹿邑县| 宜章县| 张家川| 天长市| 东阿县| 宜黄县|