listdocpagniator.java

来自「cwbbs 云网论坛源码」· Java 代码 · 共 85 行

JAVA
85
字号
package cn.js.fan.module.cms.template;import javax.servlet.http.*;import cn.js.fan.db.*;import cn.js.fan.module.cms.*;import cn.js.fan.web.*;public class ListDocPagniator extends Paginator {    HttpServletRequest request;    static int pagePosition = 0;     public ListDocPagniator(HttpServletRequest request, long total, int pagesize) {         super(request, total, pagesize);         this.request = request;     }          public int pageNum2No(int pageNum) {         return totalpages - pageNum + 1;     }          public int pageNo2Num(int pageNo) {         return totalpages - pageNo + 1;     }          public String getHtmlCurPageBlock(Leaf lf, int curPage) {         this.curPage = curPage;         intpagenum();         if (pagenumbegin == 0)             return "";         String str = "";         String rootPath = "";         if (!Global.virtualPath.equals(""))             rootPath = "/" + Global.virtualPath;         cn.js.fan.module.cms.Config cfg = new cn.js.fan.module.cms.Config();         if (curpagenumblock > 1) {              str += "<a title='往前' href='" + rootPath + "/" + lf.getListHtmlNameByPageNo(pageNum2No(pagenumbegin - 1)) + "'>" + "上一页" + "</a> ";         }         for (int i = pagenumbegin; i <= pagenumend; i++) {             if (i == curPage)                 str += i + " ";             else                 str += "[<a href='" + rootPath + "/" + lf.getListHtmlNameByPageNo(pageNum2No(i)) + "'>" + i +                         "</a>] ";         }         if (curpagenumblock < totalpagenumblock) {              str += "<a title='往后' href='" + rootPath + "/" + lf.getListHtmlNameByPageNo(pageNum2No(pagenumend + 1)) +                     "'>" + "下一页" + "</a>";         }         String pre = "_" + pagePosition;         str += "<input name=" + "pageNum" + pre + " size=2 style=width:30px onKeyDown=" +                   "page_presskey" + pre + "(this.value)>";         str += "<input type=button value=GO onClick=" +                   "changepage" + pre + "(" + "pageNum" + pre + ".value)>";           str += "<script language='javascript'>";           str += "function changepage" + pre + "(num){";           str += "window.location.href='" + lf.getCode() + "_" + "'+(" + totalpages +                   " - num + 1)+'." + cfg.getProperty("cms.html_ext") + "';";           str += "}";           str += "function page_presskey" + pre + "(num) {";           str += "if (window.event.keyCode==13) {";           str += "changepage(num);window.event.cancelBubble=true;";           str += "}";           str += "}</script>";        pagePosition++;        if (pagePosition>500) {            pagePosition = 0;        }         return str;    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?