PageBean分页组件
Posted 光何
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PageBean分页组件相关的知识,希望对你有一定的参考价值。
Page.java
1 package org.guangsoft.bean;
2
3 import java.util.List;
4
5 public class Page
6 {
7 private int currentPageNum;
8 private int pageItemsCount;
9 private int totalItemsCount;
10
11 private int pageItemsStart;
12 private int pageItemsEnd;
13 private int pageCount;
14 private boolean hasPrePage;
15 private boolean hasNextPage;
16 private int prePageNum;
17 private int nextPageNum;
18 private int firstPageNum;
19 private int lastPageNum;
20 private List dataList;
21
22 public Page()
23 {
24 super();
25 }
26 public Page(int currentPageNum, int pageItemsCount, int totalItemsCount)
27 {
28 super();
29 this.currentPageNum = currentPageNum;
30 this.pageItemsCount = pageItemsCount;
31 this.totalItemsCount = totalItemsCount;
32
33 pageItemsStart = (currentPageNum - 1) * pageItemsCount;
34 pageItemsEnd = pageItemsStart + pageItemsCount - 1;
35 pageCount = (int) Math.ceil(totalItemsCount * 1.0 / pageItemsCount);
36 firstPageNum = totalItemsCount > 0 ? 1 : 0;
37 lastPageNum = totalItemsCount > 0 ? pageCount : 0;
38 hasPrePage = currentPageNum > 1 ? true : false;
39 hasNextPage = currentPageNum < lastPageNum ? true : false;
40 prePageNum = hasPrePage ? currentPageNum - 1 : 0;
41 nextPageNum = hasNextPage ? currentPageNum + 1 : 0;
42 }
43 public int getCurrentPageNum()
44 {
45 return currentPageNum;
46 }
47 public void setCurrentPageNum(int currentPageNum)
48 {
49 this.currentPageNum = currentPageNum;
50 }
51 public int getPageItemsCount()
52 {
53 return pageItemsCount;
54 }
55 public void setPageItemsCount(int pageItemsCount)
56 {
57 this.pageItemsCount = pageItemsCount;
58 }
59 public int getTotalItemsCount()
60 {
61 return totalItemsCount;
62 }
63 public void setTotalItemsCount(int totalItemsCount)
64 {
65 this.totalItemsCount = totalItemsCount;
66 }
67 public int getPageItemsStart()
68 {
69 return pageItemsStart;
70 }
71 public void setPageItemsStart(int pageItemsStart)
72 {
73 this.pageItemsStart = pageItemsStart;
74 }
75 public int getPageItemsEnd()
76 {
77 return pageItemsEnd;
78 }
79 public void setPageItemsEnd(int pageItemsEnd)
80 {
81 this.pageItemsEnd = pageItemsEnd;
82 }
83 public int getpageCount()
84 {
85 return pageCount;
86 }
87 public void setpageCount(int pageCount)
88 {
89 this.pageCount = pageCount;
90 }
91 public boolean isHasPrePage()
92 {
93 return hasPrePage;
94 }
95 public void setHasPrePage(boolean hasPrePage)
96 {
97 this.hasPrePage = hasPrePage;
98 }
99 public boolean isHasNextPage()
100 {
101 return hasNextPage;
102 }
103 public void setHasNextPage(boolean hasNextPage)
104 {
105 this.hasNextPage = hasNextPage;
106 }
107 public int getPrePageNum()
108 {
109 return prePageNum;
110 }
111 public void setPrePageNum(int prePageNum)
112 {
113 this.prePageNum = prePageNum;
114 }
115 public int getNextPageNum()
116 {
117 return nextPageNum;
118 }
119 public void setNextPageNum(int nextPageNum)
120 {
121 this.nextPageNum = nextPageNum;
122 }
123 public int getFirstPageNum()
124 {
125 return firstPageNum;
126 }
127 public void setFirstPageNum(int firstPageNum)
128 {
129 this.firstPageNum = firstPageNum;
130 }
131 public int getLastPageNum()
132 {
133 return lastPageNum;
134 }
135 public void setLastPageNum(int lastPageNum)
136 {
137 this.lastPageNum = lastPageNum;
138 }
139 public List getDataList()
140 {
141 return dataList;
142 }
143 public void setDataList(List dataList)
144 {
145 this.dataList = dataList;
146 }
147 }
以上是关于PageBean分页组件的主要内容,如果未能解决你的问题,请参考以下文章