1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.uif.element;
17
18 import org.kuali.rice.krad.datadictionary.parse.BeanTag;
19 import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
20 import org.kuali.rice.krad.uif.util.LifecycleElement;
21
22
23
24
25
26
27
28
29
30
31 @BeanTag(name = "numberedPager", parent = "Uif-NumberedPager")
32 public class NumberedPager extends Pager {
33 private static final long serialVersionUID = -6495003633052595157L;
34
35 private int maxNumberedLinksShown;
36 private boolean renderPrevNext;
37 private boolean renderFirstLast;
38
39 protected int pagesStart;
40 protected int pagesEnd;
41
42 private String firstText;
43 private String lastText;
44
45
46
47
48
49
50
51
52 @Override
53 public void performFinalize(Object model, LifecycleElement parent) {
54 super.performFinalize(model, parent);
55
56 if (maxNumberedLinksShown >= this.getNumberOfPages()) {
57
58 pagesStart = 1;
59 pagesEnd = this.getNumberOfPages();
60 } else {
61
62 int beforeAfterShown = (int) Math.floor((double) maxNumberedLinksShown / 2.0);
63 pagesStart = this.getCurrentPage() - beforeAfterShown;
64 pagesEnd = this.getCurrentPage() + beforeAfterShown;
65
66
67
68 if (pagesEnd - pagesStart == maxNumberedLinksShown) {
69 pagesEnd = pagesEnd - 1;
70 }
71
72
73 if (pagesEnd > this.getNumberOfPages()) {
74 pagesEnd = this.getNumberOfPages();
75 pagesStart = this.getNumberOfPages() - maxNumberedLinksShown + 1;
76 }
77
78
79 if (pagesStart < 1) {
80 pagesStart = 1;
81 if (maxNumberedLinksShown < this.getNumberOfPages()) {
82 pagesEnd = maxNumberedLinksShown;
83 }
84 }
85 }
86 }
87
88
89
90
91
92
93
94
95 @BeanTagAttribute
96 public int getMaxNumberedLinksShown() {
97 return maxNumberedLinksShown;
98 }
99
100
101
102
103
104
105 public void setMaxNumberedLinksShown(int maxNumberedLinksShown) {
106 this.maxNumberedLinksShown = maxNumberedLinksShown;
107 }
108
109
110
111
112
113
114 @BeanTagAttribute
115 public boolean isRenderFirstLast() {
116 return renderFirstLast;
117 }
118
119
120
121
122
123
124 public void setRenderFirstLast(boolean renderFirstLast) {
125 this.renderFirstLast = renderFirstLast;
126 }
127
128
129
130
131
132
133 @BeanTagAttribute
134 public boolean isRenderPrevNext() {
135 return renderPrevNext;
136 }
137
138
139
140
141
142
143 public void setRenderPrevNext(boolean renderPrevNext) {
144 this.renderPrevNext = renderPrevNext;
145 }
146
147
148
149
150
151
152 public int getPagesStart() {
153 return pagesStart;
154 }
155
156
157
158
159
160
161 public int getPagesEnd() {
162 return pagesEnd;
163 }
164
165
166
167
168
169
170 @BeanTagAttribute
171 public String getFirstText() {
172 return firstText;
173 }
174
175
176
177
178 public void setFirstText(String firstText) {
179 this.firstText = firstText;
180 }
181
182
183
184
185
186
187 @BeanTagAttribute
188 public String getLastText() {
189 return lastText;
190 }
191
192
193
194
195 public void setLastText(String lastText) {
196 this.lastText = lastText;
197 }
198
199 }