1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.uif.view;
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.container.CollectionGroup;
22 import org.kuali.rice.krad.uif.container.Group;
23 import org.kuali.rice.krad.uif.component.Component;
24 import org.kuali.rice.krad.uif.component.RequestParameter;
25 import org.kuali.rice.krad.uif.field.Field;
26 import org.kuali.rice.krad.web.form.LookupForm;
27
28 import java.util.Arrays;
29 import java.util.List;
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48 public class LookupView extends FormView {
49 private static final long serialVersionUID = 716926008488403616L;
50
51 private Class<?> dataObjectClassName;
52
53 private Group criteriaGroup;
54 private CollectionGroup resultsGroup;
55
56 private Field resultsActionsField;
57 private Field resultsReturnField;
58
59 private List<Component> criteriaFields;
60 private List<Component> resultFields;
61 private List<String> defaultSortAttributeNames;
62
63 protected boolean defaultSortAscending = true;
64
65 @RequestParameter
66 private boolean hideReturnLinks = false;
67 @RequestParameter
68 private boolean suppressActions = false;
69 @RequestParameter
70 private boolean showMaintenanceLinks = false;
71 @RequestParameter
72 private boolean multipleValuesSelect = false;
73
74 @RequestParameter
75 private String returnTarget;
76
77 @RequestParameter
78 private boolean returnByScript;
79
80 private boolean lookupCriteriaEnabled = true;
81 private boolean supplementalActionsEnabled = false;
82 private boolean disableSearchButtons = false;
83
84 private Integer resultSetLimit = null;
85
86 private String maintenanceUrlMapping;
87
88 public LookupView() {
89 super();
90 setViewTypeName(ViewType.LOOKUP);
91 setValidateDirty(false);
92 }
93
94
95
96
97
98
99
100
101
102
103 @Override
104 public void performInitialization(View view, Object model) {
105 initializeGroups();
106 if (getItems().isEmpty()) {
107 setItems(Arrays.asList(getCriteriaGroup(), getResultsGroup()));
108 }
109 super.performInitialization(view, model);
110
111 getAbstractTypeClasses().put(UifPropertyPaths.CRITERIA_FIELDS, getDataObjectClassName());
112 if (StringUtils.isNotBlank(getDefaultBindingObjectPath())) {
113 getAbstractTypeClasses().put(getDefaultBindingObjectPath(), getDataObjectClassName());
114 }
115 }
116
117 protected void initializeGroups() {
118 if ((getCriteriaGroup() != null) && (getCriteriaGroup().getItems().isEmpty())) {
119 getCriteriaGroup().setItems(getCriteriaFields());
120 }
121 if (getResultsGroup() != null) {
122 if ((getResultsGroup().getItems().isEmpty()) && (getResultFields() != null)) {
123 getResultsGroup().setItems(getResultFields());
124 }
125 if (getResultsGroup().getCollectionObjectClass() == null) {
126 getResultsGroup().setCollectionObjectClass(getDataObjectClassName());
127 }
128 }
129 }
130
131
132
133
134
135 @Override
136 public void performApplyModel(View view, Object model, Component parent) {
137 LookupForm lookupForm = (LookupForm) model;
138
139
140 if (!isSuppressActions() && isShowMaintenanceLinks()) {
141 ((List<Field>) getResultsGroup().getItems()).add(0, getResultsActionsField());
142 }
143
144 if (StringUtils.isNotBlank(lookupForm.getReturnFormKey()) &&
145 StringUtils.isNotBlank(lookupForm.getReturnLocation()) && !isHideReturnLinks()) {
146 ((List<Field>) getResultsGroup().getItems()).add(0, getResultsReturnField());
147 }
148
149 super.performApplyModel(view, model, parent);
150 }
151
152
153
154
155 @Override
156 public List<Component> getComponentPrototypes() {
157 List<Component> components = super.getComponentPrototypes();
158
159 components.add(criteriaGroup);
160 components.add(resultsGroup);
161 components.add(resultsActionsField);
162 components.add(resultsReturnField);
163 components.addAll(criteriaFields);
164 components.addAll(resultFields);
165
166 return components;
167 }
168
169 public void applyConditionalLogicForFieldDisplay() {
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194 }
195
196
197
198
199
200
201
202
203
204
205
206
207
208 public Class<?> getDataObjectClassName() {
209 return this.dataObjectClassName;
210 }
211
212
213
214
215
216
217 public void setDataObjectClassName(Class<?> dataObjectClassName) {
218 this.dataObjectClassName = dataObjectClassName;
219 }
220
221
222
223
224 public boolean isHideReturnLinks() {
225 return this.hideReturnLinks;
226 }
227
228
229
230
231 public void setHideReturnLinks(boolean hideReturnLinks) {
232 this.hideReturnLinks = hideReturnLinks;
233 }
234
235
236
237
238 public boolean isSuppressActions() {
239 return this.suppressActions;
240 }
241
242
243
244
245 public void setSuppressActions(boolean suppressActions) {
246 this.suppressActions = suppressActions;
247 }
248
249
250
251
252 public boolean isShowMaintenanceLinks() {
253 return this.showMaintenanceLinks;
254 }
255
256
257
258
259 public void setShowMaintenanceLinks(boolean showMaintenanceLinks) {
260 this.showMaintenanceLinks = showMaintenanceLinks;
261 }
262
263
264
265
266
267
268
269
270
271
272
273 public boolean isMultipleValuesSelect() {
274 return multipleValuesSelect;
275 }
276
277
278
279
280
281
282 public void setMultipleValuesSelect(boolean multipleValuesSelect) {
283 this.multipleValuesSelect = multipleValuesSelect;
284 }
285
286
287
288
289 public Field getResultsActionsField() {
290 return this.resultsActionsField;
291 }
292
293
294
295
296 public void setResultsActionsField(Field resultsActionsField) {
297 this.resultsActionsField = resultsActionsField;
298 }
299
300
301
302
303 public Field getResultsReturnField() {
304 return this.resultsReturnField;
305 }
306
307
308
309
310 public void setResultsReturnField(Field resultsReturnField) {
311 this.resultsReturnField = resultsReturnField;
312 }
313
314 public Group getCriteriaGroup() {
315 return this.criteriaGroup;
316 }
317
318 public void setCriteriaGroup(Group criteriaGroup) {
319 this.criteriaGroup = criteriaGroup;
320 }
321
322 public CollectionGroup getResultsGroup() {
323 return this.resultsGroup;
324 }
325
326 public void setResultsGroup(CollectionGroup resultsGroup) {
327 this.resultsGroup = resultsGroup;
328 }
329
330 public List<Component> getCriteriaFields() {
331 return this.criteriaFields;
332 }
333
334 public void setCriteriaFields(List<Component> criteriaFields) {
335 this.criteriaFields = criteriaFields;
336 }
337
338 public List<Component> getResultFields() {
339 return this.resultFields;
340 }
341
342 public void setResultFields(List<Component> resultFields) {
343 this.resultFields = resultFields;
344 }
345
346 public List<String> getDefaultSortAttributeNames() {
347 return this.defaultSortAttributeNames;
348 }
349
350 public void setDefaultSortAttributeNames(List<String> defaultSortAttributeNames) {
351 this.defaultSortAttributeNames = defaultSortAttributeNames;
352 }
353
354 public boolean isDefaultSortAscending() {
355 return this.defaultSortAscending;
356 }
357
358 public void setDefaultSortAscending(boolean defaultSortAscending) {
359 this.defaultSortAscending = defaultSortAscending;
360 }
361
362
363
364
365
366
367
368 public Integer getResultSetLimit() {
369 return resultSetLimit;
370 }
371
372
373
374
375
376
377 public void setResultSetLimit(Integer resultSetLimit) {
378 this.resultSetLimit = resultSetLimit;
379 }
380
381
382
383
384
385
386
387 public boolean hasResultSetLimit() {
388 return (resultSetLimit != null);
389 }
390
391
392
393
394 public void setReturnTarget(String returnTarget) {
395 this.returnTarget = returnTarget;
396 }
397
398
399
400
401 public String getReturnTarget() {
402 return returnTarget;
403 }
404
405
406
407
408 public boolean isReturnByScript() {
409 return returnByScript;
410 }
411
412
413
414
415
416
417
418 public void setReturnByScript(boolean returnByScript) {
419 this.returnByScript = returnByScript;
420 }
421
422
423
424
425
426
427
428
429
430
431
432
433 public String getMaintenanceUrlMapping() {
434 return maintenanceUrlMapping;
435 }
436
437
438
439
440
441
442 public void setMaintenanceUrlMapping(String maintenanceUrlMapping) {
443 this.maintenanceUrlMapping = maintenanceUrlMapping;
444 }
445 }