1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.uif.container;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.krad.uif.UifConstants.ViewType;
20 import org.kuali.rice.krad.uif.UifPropertyPaths;
21 import org.kuali.rice.krad.uif.core.Component;
22 import org.kuali.rice.krad.uif.core.RequestParameter;
23 import org.kuali.rice.krad.uif.field.Field;
24 import org.kuali.rice.krad.web.form.LookupForm;
25
26 import java.util.Arrays;
27 import java.util.List;
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46 public class LookupView extends FormView {
47 private static final long serialVersionUID = 716926008488403616L;
48
49 private Class<?> dataObjectClassName;
50
51 private Group criteriaGroup;
52 private CollectionGroup resultsGroup;
53
54 private Field resultsActionsField;
55 private Field resultsReturnField;
56
57 private List<Component> criteriaFields;
58 private List<Component> resultFields;
59 private List<String> defaultSortAttributeNames;
60
61 protected boolean sortAscending = true;
62
63 @RequestParameter
64 private boolean hideReturnLinks = false;
65 @RequestParameter
66 private boolean suppressActions = false;
67 @RequestParameter
68 private boolean showMaintenanceLinks = false;
69
70 private boolean multipleValues = false;
71 private boolean lookupCriteriaEnabled = true;
72 private boolean supplementalActionsEnabled = false;
73 private boolean disableSearchButtons = false;
74
75 private Integer resultSetLimit = null;
76
77 public LookupView() {
78 super();
79 setViewTypeName(ViewType.LOOKUP);
80 setValidateDirty(false);
81 }
82
83
84
85
86
87
88
89
90
91
92 @Override
93 public void performInitialization(View view) {
94 initializeGroups();
95 if (getItems().isEmpty()) {
96 setItems(Arrays.asList(getCriteriaGroup(), getResultsGroup()));
97 }
98 super.performInitialization(view);
99
100 getAbstractTypeClasses().put(UifPropertyPaths.CRITERIA_FIELDS, getDataObjectClassName());
101 if (StringUtils.isNotBlank(getDefaultBindingObjectPath())) {
102 getAbstractTypeClasses().put(getDefaultBindingObjectPath(), getDataObjectClassName());
103 }
104 }
105
106 protected void initializeGroups() {
107 if ((getCriteriaGroup() != null) && (getCriteriaGroup().getItems().isEmpty())) {
108 getCriteriaGroup().setItems(getCriteriaFields());
109 }
110 if (getResultsGroup() != null) {
111 if ((getResultsGroup().getItems().isEmpty()) && (getResultFields() != null)) {
112 getResultsGroup().setItems(getResultFields());
113 }
114 if (getResultsGroup().getCollectionObjectClass() == null) {
115 getResultsGroup().setCollectionObjectClass(getDataObjectClassName());
116 }
117 }
118 }
119
120
121
122
123
124 @Override
125 public void performApplyModel(View view, Object model, Component parent) {
126 LookupForm lookupForm = (LookupForm) model;
127
128
129
130 if (!isSuppressActions() && isShowMaintenanceLinks()) {
131 ((List<Field>) getResultsGroup().getItems()).add(0, getResultsActionsField());
132 }
133
134 if (StringUtils.isNotBlank(lookupForm.getReturnFormKey()) &&
135 StringUtils.isNotBlank(lookupForm.getReturnLocation()) && !isHideReturnLinks()) {
136 ((List<Field>) getResultsGroup().getItems()).add(0, getResultsReturnField());
137 }
138
139 super.performApplyModel(view, model, parent);
140 }
141
142 public void applyConditionalLogicForFieldDisplay() {
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167 }
168
169
170
171
172
173
174
175
176
177
178
179
180
181 public Class<?> getDataObjectClassName() {
182 return this.dataObjectClassName;
183 }
184
185
186
187
188
189
190 public void setDataObjectClassName(Class<?> dataObjectClassName) {
191 this.dataObjectClassName = dataObjectClassName;
192 }
193
194
195
196
197 public boolean isHideReturnLinks() {
198 return this.hideReturnLinks;
199 }
200
201
202
203
204 public void setHideReturnLinks(boolean hideReturnLinks) {
205 this.hideReturnLinks = hideReturnLinks;
206 }
207
208
209
210
211 public boolean isSuppressActions() {
212 return this.suppressActions;
213 }
214
215
216
217
218 public void setSuppressActions(boolean suppressActions) {
219 this.suppressActions = suppressActions;
220 }
221
222
223
224
225 public boolean isShowMaintenanceLinks() {
226 return this.showMaintenanceLinks;
227 }
228
229
230
231
232 public void setShowMaintenanceLinks(boolean showMaintenanceLinks) {
233 this.showMaintenanceLinks = showMaintenanceLinks;
234 }
235
236
237
238
239 public Field getResultsActionsField() {
240 return this.resultsActionsField;
241 }
242
243
244
245
246 public void setResultsActionsField(Field resultsActionsField) {
247 this.resultsActionsField = resultsActionsField;
248 }
249
250
251
252
253 public Field getResultsReturnField() {
254 return this.resultsReturnField;
255 }
256
257
258
259
260 public void setResultsReturnField(Field resultsReturnField) {
261 this.resultsReturnField = resultsReturnField;
262 }
263
264 public Group getCriteriaGroup() {
265 return this.criteriaGroup;
266 }
267
268 public void setCriteriaGroup(Group criteriaGroup) {
269 this.criteriaGroup = criteriaGroup;
270 }
271
272 public CollectionGroup getResultsGroup() {
273 return this.resultsGroup;
274 }
275
276 public void setResultsGroup(CollectionGroup resultsGroup) {
277 this.resultsGroup = resultsGroup;
278 }
279
280 public List<Component> getCriteriaFields() {
281 return this.criteriaFields;
282 }
283
284 public void setCriteriaFields(List<Component> criteriaFields) {
285 this.criteriaFields = criteriaFields;
286 }
287
288 public List<Component> getResultFields() {
289 return this.resultFields;
290 }
291
292 public void setResultFields(List<Component> resultFields) {
293 this.resultFields = resultFields;
294 }
295
296 public List<String> getDefaultSortAttributeNames() {
297 return this.defaultSortAttributeNames;
298 }
299
300 public void setDefaultSortAttributeNames(List<String> defaultSortAttributeNames) {
301 this.defaultSortAttributeNames = defaultSortAttributeNames;
302 }
303
304 public boolean isSortAscending() {
305 return this.sortAscending;
306 }
307
308 public void setSortAscending(boolean sortAscending) {
309 this.sortAscending = sortAscending;
310 }
311
312
313
314
315
316
317
318 public Integer getResultSetLimit() {
319 return resultSetLimit;
320 }
321
322
323
324
325
326
327 public void setResultSetLimit(Integer resultSetLimit) {
328 this.resultSetLimit = resultSetLimit;
329 }
330
331
332
333
334
335
336
337 public boolean hasResultSetLimit() {
338 return (resultSetLimit != null);
339 }
340 }