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 public LookupView() {
87 super();
88 setViewTypeName(ViewType.LOOKUP);
89 setValidateDirty(false);
90 }
91
92
93
94
95
96
97
98
99
100
101 @Override
102 public void performInitialization(View view, Object model) {
103 initializeGroups();
104 if (getItems().isEmpty()) {
105 setItems(Arrays.asList(getCriteriaGroup(), getResultsGroup()));
106 }
107 super.performInitialization(view, model);
108
109 getAbstractTypeClasses().put(UifPropertyPaths.CRITERIA_FIELDS, getDataObjectClassName());
110 if (StringUtils.isNotBlank(getDefaultBindingObjectPath())) {
111 getAbstractTypeClasses().put(getDefaultBindingObjectPath(), getDataObjectClassName());
112 }
113 }
114
115 protected void initializeGroups() {
116 if ((getCriteriaGroup() != null) && (getCriteriaGroup().getItems().isEmpty())) {
117 getCriteriaGroup().setItems(getCriteriaFields());
118 }
119 if (getResultsGroup() != null) {
120 if ((getResultsGroup().getItems().isEmpty()) && (getResultFields() != null)) {
121 getResultsGroup().setItems(getResultFields());
122 }
123 if (getResultsGroup().getCollectionObjectClass() == null) {
124 getResultsGroup().setCollectionObjectClass(getDataObjectClassName());
125 }
126 }
127 }
128
129
130
131
132
133 @Override
134 public void performApplyModel(View view, Object model, Component parent) {
135 LookupForm lookupForm = (LookupForm) model;
136
137
138 if (!isSuppressActions() && isShowMaintenanceLinks()) {
139 ((List<Field>) getResultsGroup().getItems()).add(0, getResultsActionsField());
140 }
141
142 if (StringUtils.isNotBlank(lookupForm.getReturnFormKey()) &&
143 StringUtils.isNotBlank(lookupForm.getReturnLocation()) && !isHideReturnLinks()) {
144 ((List<Field>) getResultsGroup().getItems()).add(0, getResultsReturnField());
145 }
146
147 super.performApplyModel(view, model, parent);
148 }
149
150 public void applyConditionalLogicForFieldDisplay() {
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
182
183
184
185
186
187
188
189 public Class<?> getDataObjectClassName() {
190 return this.dataObjectClassName;
191 }
192
193
194
195
196
197
198 public void setDataObjectClassName(Class<?> dataObjectClassName) {
199 this.dataObjectClassName = dataObjectClassName;
200 }
201
202
203
204
205 public boolean isHideReturnLinks() {
206 return this.hideReturnLinks;
207 }
208
209
210
211
212 public void setHideReturnLinks(boolean hideReturnLinks) {
213 this.hideReturnLinks = hideReturnLinks;
214 }
215
216
217
218
219 public boolean isSuppressActions() {
220 return this.suppressActions;
221 }
222
223
224
225
226 public void setSuppressActions(boolean suppressActions) {
227 this.suppressActions = suppressActions;
228 }
229
230
231
232
233 public boolean isShowMaintenanceLinks() {
234 return this.showMaintenanceLinks;
235 }
236
237
238
239
240 public void setShowMaintenanceLinks(boolean showMaintenanceLinks) {
241 this.showMaintenanceLinks = showMaintenanceLinks;
242 }
243
244
245
246
247
248
249
250
251
252
253
254 public boolean isMultipleValuesSelect() {
255 return multipleValuesSelect;
256 }
257
258
259
260
261
262
263 public void setMultipleValuesSelect(boolean multipleValuesSelect) {
264 this.multipleValuesSelect = multipleValuesSelect;
265 }
266
267
268
269
270 public Field getResultsActionsField() {
271 return this.resultsActionsField;
272 }
273
274
275
276
277 public void setResultsActionsField(Field resultsActionsField) {
278 this.resultsActionsField = resultsActionsField;
279 }
280
281
282
283
284 public Field getResultsReturnField() {
285 return this.resultsReturnField;
286 }
287
288
289
290
291 public void setResultsReturnField(Field resultsReturnField) {
292 this.resultsReturnField = resultsReturnField;
293 }
294
295 public Group getCriteriaGroup() {
296 return this.criteriaGroup;
297 }
298
299 public void setCriteriaGroup(Group criteriaGroup) {
300 this.criteriaGroup = criteriaGroup;
301 }
302
303 public CollectionGroup getResultsGroup() {
304 return this.resultsGroup;
305 }
306
307 public void setResultsGroup(CollectionGroup resultsGroup) {
308 this.resultsGroup = resultsGroup;
309 }
310
311 public List<Component> getCriteriaFields() {
312 return this.criteriaFields;
313 }
314
315 public void setCriteriaFields(List<Component> criteriaFields) {
316 this.criteriaFields = criteriaFields;
317 }
318
319 public List<Component> getResultFields() {
320 return this.resultFields;
321 }
322
323 public void setResultFields(List<Component> resultFields) {
324 this.resultFields = resultFields;
325 }
326
327 public List<String> getDefaultSortAttributeNames() {
328 return this.defaultSortAttributeNames;
329 }
330
331 public void setDefaultSortAttributeNames(List<String> defaultSortAttributeNames) {
332 this.defaultSortAttributeNames = defaultSortAttributeNames;
333 }
334
335 public boolean isDefaultSortAscending() {
336 return this.defaultSortAscending;
337 }
338
339 public void setDefaultSortAscending(boolean defaultSortAscending) {
340 this.defaultSortAscending = defaultSortAscending;
341 }
342
343
344
345
346
347
348
349 public Integer getResultSetLimit() {
350 return resultSetLimit;
351 }
352
353
354
355
356
357
358 public void setResultSetLimit(Integer resultSetLimit) {
359 this.resultSetLimit = resultSetLimit;
360 }
361
362
363
364
365
366
367
368 public boolean hasResultSetLimit() {
369 return (resultSetLimit != null);
370 }
371
372
373
374
375 public void setReturnTarget(String returnTarget) {
376 this.returnTarget = returnTarget;
377 }
378
379
380
381
382 public String getReturnTarget() {
383 return returnTarget;
384 }
385
386
387
388
389 public boolean isReturnByScript() {
390 return returnByScript;
391 }
392
393
394
395
396
397
398
399 public void setReturnByScript(boolean returnByScript) {
400 this.returnByScript = returnByScript;
401 }
402 }