ageNo(String pageNo) {
33 this.pageNo = pageNo;
34 }
35 public void setTotal(String total) {
36 this.total = total;
37 }
38 public String getIncludes() {
39 return includes;
40 }
41 public void setIncludes(String includes) {
42 this.includes = includes;
43 }
44
45 @Override
46 public Component getBean(ValueStack arg0, HttpServletRequest arg1, HttpServletResponse arg2) {
47 return new Pages(arg0, arg1);
48 }
49
50 protected void populateParams() {
51 super.populateParams();
52
53 Pages pages = (Pages)component;
54 pages.setPageNo(pageNo);
55 pages.setIncludes(includes);
56 pages.setTotal(total);
57 pages.setStyleClass(styleClass);
58 pages.setTheme(theme);
59
60 }
61}
分页标签(4)
时间:2011-01-21 BlogJava tobyxiong
4.页面应用
<%@ taglib prefix="tangs" uri="/WEB-INF/pagination.tld"%>
<tangs:pages pageNo="pageNo" total="total" theme="text"/>
5.action代码片段
private Integer total;
private Integer pageNo=1;
public String listAllHotNews(){
pageConfig.setAllRecordNum(dao.recordCount());
total = pageConfig.getAllPageNum();
int start = pageConfig.getPerRecordNum()* (pageNo - 1);
int size = pageConfig.getPerRecordNum();
hotNewsList = dao.listAllNews(start,size);
return SUCCESS;
}
6.pageConfig.java
1package cn.com.sunrise.home.credit.page;
2
3import cn.com.sunrise.home.util.Constraint;
4
5public class PageConfig {
6 private int allRecordNum;// 总记录数
7
8 private int allPageNum;// 总页数
9
10 private int perRecordNum =Constraint.PAGESIZE;// 每页显示数
11
12 private int currPageNO;// 当前页号
13
14 // 分页提供存取方法
15 public int getAllRecordNum() {
16 return allRecordNum;
17 }
18 //得到总页数,用下面的算法
19 public void setAllRecordNum(int allRecordNum) {
20 this.allRecordNum = allRecordNum;
21 if(allRecordNum % perRecordNum == 0){
22 this.allPageNum = allRecordNum / perRecordNum;
23 }else{
24 this.allPageNum = allRecordNum / perRecordNum + 1;
25 }
26 }
27
28 public int getAllPageNum() {
29 return allPageNum;
30 }
31
32 public void setAllPageNum(int allPageNum) {
33 this.allPageNum = allPageNum;
34 }
35
36 public int getPerRecordNum() {
37 return perRecordNum;
38 }
39
40 public void setPerRecordNum(int perRecordNum) {
41 this.perRecordNum = perRecordNum;
42 }
43
44 public int getCur
|