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
112 if (multipleValuesSelect) {
113 hideReturnLinks = true;
114 }
115
116 getAbstractTypeClasses().put(UifPropertyPaths.CRITERIA_FIELDS, getDataObjectClassName());
117 if (StringUtils.isNotBlank(getDefaultBindingObjectPath())) {
118 getAbstractTypeClasses().put(getDefaultBindingObjectPath(), getDataObjectClassName());
119 }
120 }
121
122 protected void initializeGroups() {
123 if ((getCriteriaGroup() != null) && (getCriteriaGroup().getItems().isEmpty())) {
124 getCriteriaGroup().setItems(getCriteriaFields());
125 }
126 if (getResultsGroup() != null) {
127 if ((getResultsGroup().getItems().isEmpty()) && (getResultFields() != null)) {
128 getResultsGroup().setItems(getResultFields());
129 }
130 if (getResultsGroup().getCollectionObjectClass() == null) {
131 getResultsGroup().setCollectionObjectClass(getDataObjectClassName());
132 }
133 }
134 }
135
136
137
138
139
140 @Override
141 public void performApplyModel(View view, Object model, Component parent) {
142 LookupForm lookupForm = (LookupForm) model;
143
144
145 if (!isSuppressActions() && isShowMaintenanceLinks()) {
146 ((List<Field>) getResultsGroup().getItems()).add(0, getResultsActionsField());
147 }
148
149 if (StringUtils.isNotBlank(lookupForm.getReturnFormKey()) &&
150 StringUtils.isNotBlank(lookupForm.getReturnLocation()) && !isHideReturnLinks()) {
151 ((List<Field>) getResultsGroup().getItems()).add(0, getResultsReturnField());
152 }
153
154 super.performApplyModel(view, model, parent);
155 }
156
157
158
159
160 @Override
161 public List<Component> getComponentPrototypes() {
162 List<Component> components = super.getComponentPrototypes();
163
164 components.add(criteriaGroup);
165 components.add(resultsGroup);
166 components.add(resultsActionsField);
167 components.add(resultsReturnField);
168 components.addAll(criteriaFields);
169 components.addAll(resultFields);
170
171 return components;
172 }
173
174 public void applyConditionalLogicForFieldDisplay() {
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
209
210
211
212
213 public Class<?> getDataObjectClassName() {
214 return this.dataObjectClassName;
215 }
216
217
218
219
220
221
222 public void setDataObjectClassName(Class<?> dataObjectClassName) {
223 this.dataObjectClassName = dataObjectClassName;
224 }
225
226
227
228
229 public boolean isHideReturnLinks() {
230 return this.hideReturnLinks;
231 }
232
233
234
235
236 public void setHideReturnLinks(boolean hideReturnLinks) {
237 this.hideReturnLinks = hideReturnLinks;
238 }
239
240
241
242
243 public boolean isSuppressActions() {
244 return this.suppressActions;
245 }
246
247
248
249
250 public void setSuppressActions(boolean suppressActions) {
251 this.suppressActions = suppressActions;
252 }
253
254
255
256
257 public boolean isShowMaintenanceLinks() {
258 return this.showMaintenanceLinks;
259 }
260
261
262
263
264 public void setShowMaintenanceLinks(boolean showMaintenanceLinks) {
265 this.showMaintenanceLinks = showMaintenanceLinks;
266 }
267
268
269
270
271
272
273
274
275
276
277
278 public boolean isMultipleValuesSelect() {
279 return multipleValuesSelect;
280 }
281
282
283
284
285
286
287 public void setMultipleValuesSelect(boolean multipleValuesSelect) {
288 this.multipleValuesSelect = multipleValuesSelect;
289 }
290
291
292
293
294 public Field getResultsActionsField() {
295 return this.resultsActionsField;
296 }
297
298
299
300
301 public void setResultsActionsField(Field resultsActionsField) {
302 this.resultsActionsField = resultsActionsField;
303 }
304
305
306
307
308 public Field getResultsReturnField() {
309 return this.resultsReturnField;
310 }
311
312
313
314
315 public void setResultsReturnField(Field resultsReturnField) {
316 this.resultsReturnField = resultsReturnField;
317 }
318
319 public Group getCriteriaGroup() {
320 return this.criteriaGroup;
321 }
322
323 public void setCriteriaGroup(Group criteriaGroup) {
324 this.criteriaGroup = criteriaGroup;
325 }
326
327 public CollectionGroup getResultsGroup() {
328 return this.resultsGroup;
329 }
330
331 public void setResultsGroup(CollectionGroup resultsGroup) {
332 this.resultsGroup = resultsGroup;
333 }
334
335 public List<Component> getCriteriaFields() {
336 return this.criteriaFields;
337 }
338
339 public void setCriteriaFields(List<Component> criteriaFields) {
340 this.criteriaFields = criteriaFields;
341 }
342
343 public List<Component> getResultFields() {
344 return this.resultFields;
345 }
346
347 public void setResultFields(List<Component> resultFields) {
348 this.resultFields = resultFields;
349 }
350
351 public List<String> getDefaultSortAttributeNames() {
352 return this.defaultSortAttributeNames;
353 }
354
355 public void setDefaultSortAttributeNames(List<String> defaultSortAttributeNames) {
356 this.defaultSortAttributeNames = defaultSortAttributeNames;
357 }
358
359 public boolean isDefaultSortAscending() {
360 return this.defaultSortAscending;
361 }
362
363 public void setDefaultSortAscending(boolean defaultSortAscending) {
364 this.defaultSortAscending = defaultSortAscending;
365 }
366
367
368
369
370
371
372
373 public Integer getResultSetLimit() {
374 return resultSetLimit;
375 }
376
377
378
379
380
381
382 public void setResultSetLimit(Integer resultSetLimit) {
383 this.resultSetLimit = resultSetLimit;
384 }
385
386
387
388
389
390
391
392 public boolean hasResultSetLimit() {
393 return (resultSetLimit != null);
394 }
395
396
397
398
399 public void setReturnTarget(String returnTarget) {
400 this.returnTarget = returnTarget;
401 }
402
403
404
405
406 public String getReturnTarget() {
407 return returnTarget;
408 }
409
410
411
412
413 public boolean isReturnByScript() {
414 return returnByScript;
415 }
416
417
418
419
420
421
422
423 public void setReturnByScript(boolean returnByScript) {
424 this.returnByScript = returnByScript;
425 }
426
427
428
429
430
431
432
433
434
435
436
437
438 public String getMaintenanceUrlMapping() {
439 return maintenanceUrlMapping;
440 }
441
442
443
444
445
446
447 public void setMaintenanceUrlMapping(String maintenanceUrlMapping) {
448 this.maintenanceUrlMapping = maintenanceUrlMapping;
449 }
450 }