夢幻之旅

          DEBUG - 天道酬勤

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

          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">
           總行數(shù)#totalRowCount#   
          |  
           總頁數(shù)#totalPageCount#  
          |
           當前第#currentPageNum#頁  
          |
           每頁數(shù)#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 閱讀(444) 評論(0)  編輯  收藏 所屬分類: Java
          主站蜘蛛池模板: 潜山县| 会理县| 辽阳县| 洞头县| 莱芜市| 内乡县| 衡山县| 安远县| 突泉县| 仁布县| 淮滨县| 眉山市| 海伦市| 三亚市| 哈巴河县| 商河县| 科技| 奎屯市| 滦平县| 长春市| 桐城市| 浏阳市| 晋江市| 灵宝市| 微山县| 双辽市| 勐海县| 鸡东县| 金昌市| 文昌市| 建阳市| 和顺县| 宜宾市| 油尖旺区| 长沙市| 镇宁| 道真| 保德县| 敖汉旗| 鹤岗市| 巴彦县|