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