package com.fh.entity; import com.fh.util.Const; import com.fh.util.PageData; import com.fh.util.Tools; public class Page { private int showCount; //每页显示记录数 private int totalPage; //总页数 private int totalResult; //总记录数 private int currentPage; //当前页 private int currentResult; //当前记录起始索引 private boolean entityOrField; //true:需要分页的地方,传入的参数就是Page实体;false:需要分页的地方,传入的参数所代表的实体拥有Page属性 private String pageStr; //最终页面显示的底部翻页导航,详细见:getPageStr(); private PageData pd = new PageData(); public Page(){ try { this.showCount = Integer.parseInt(Tools.readTxtFile(Const.PAGE)); } catch (Exception e) { this.showCount = 15; } } public int getTotalPage() { if(totalResult%showCount==0) totalPage = totalResult/showCount; else totalPage = totalResult/showCount+1; return totalPage; } public void setTotalPage(int totalPage) { this.totalPage = totalPage; } public int getTotalResult() { return totalResult; } public void setTotalResult(int totalResult) { this.totalResult = totalResult; } public int getCurrentPage() { if(currentPage<=0) currentPage = 1; if(currentPage>getTotalPage()) currentPage = getTotalPage(); return currentPage; } public void setCurrentPage(int currentPage) { this.currentPage = currentPage; } private String total = "共" ; private String articles = "条"; private String frist = "首页" ; private String previous = "上一页"; private String next = "下一页"; private String tail = "尾页" ; private String jump = "跳转" ; private String pageNumber = "页码"; private String displayNumber = "显示条数" ; public void setLangIsChina(boolean is){ if(is){ total = "共" ; articles = "条"; frist = "首页" ; previous = "上一页"; next = "下一页"; tail = "尾页" ; jump = "跳转" ; pageNumber = "页码"; displayNumber = "显示条数" ; }else{ total = "" ; articles = " articles"; frist = "Frist" ; previous = "Previous"; next = "Next"; tail = "Last" ; jump = "Goto" ; pageNumber = "PageNo."; displayNumber = "Display Number" ; } } //拼接分页 页面及JS函数 public String getPageStr() { StringBuffer sb = new StringBuffer(); if(totalResult>0){ sb.append("