1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.lookup;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.krad.uif.UifConstants.ViewType;
20 import org.kuali.rice.krad.util.KRADConstants;
21 import org.kuali.rice.krad.util.KRADUtils;
22 import org.kuali.rice.krad.web.bind.RequestAccessible;
23 import org.kuali.rice.krad.web.form.UifFormBase;
24 import org.springframework.http.HttpMethod;
25
26 import javax.servlet.http.HttpServletRequest;
27 import java.util.ArrayList;
28 import java.util.Collection;
29 import java.util.HashMap;
30 import java.util.List;
31 import java.util.Map;
32
33
34
35
36
37
38 public class LookupForm extends UifFormBase {
39 private static final long serialVersionUID = -7323484966538685327L;
40 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(LookupForm.class);
41
42 @RequestAccessible
43 private String dataObjectClassName;
44
45 @RequestAccessible
46 private boolean multipleValuesSelect;
47
48 @RequestAccessible
49 private boolean redirectedLookup;
50
51 @RequestAccessible
52 private boolean returnByScript;
53
54 @RequestAccessible
55 private String returnTarget;
56
57 @RequestAccessible
58 private String lookupCollectionName;
59
60 @RequestAccessible
61 private String lookupCollectionId;
62
63 @RequestAccessible
64 private String referencesToRefresh;
65
66 @RequestAccessible
67 private String quickfinderId;
68
69 @RequestAccessible
70 private Map<String, String> fieldConversions;
71 private List<String> multiValueReturnFields;
72
73 @RequestAccessible
74 private Map<String, String> lookupCriteria;
75
76 private Collection<?> lookupResults;
77
78 @RequestAccessible
79 private boolean displayResults;
80
81 public LookupForm() {
82 super();
83
84 setViewTypeName(ViewType.LOOKUP);
85
86 lookupCriteria = new HashMap<String, String>();
87 fieldConversions = new HashMap<String, String>();
88 multiValueReturnFields = new ArrayList<String>();
89 }
90
91
92
93
94
95
96
97 @Override
98 public void postBind(HttpServletRequest request) {
99 super.postBind(request);
100
101 if (StringUtils.isBlank(getDataObjectClassName())) {
102 setDataObjectClassName(((LookupView) getView()).getDataObjectClass().getName());
103 }
104
105 Lookupable lookupable = getLookupable();
106 if (lookupable != null) {
107 Class<?> dataObjectClass;
108 try {
109 dataObjectClass = Class.forName(getDataObjectClassName());
110 } catch (ClassNotFoundException e) {
111 throw new RuntimeException("Object class " + getDataObjectClassName() + " not found", e);
112 }
113
114 lookupable.setDataObjectClass(dataObjectClass);
115 }
116
117
118 if (request.getMethod().equals(HttpMethod.GET.name()) && (request.getParameter(
119 KRADConstants.CONVERSION_FIELDS_PARAMETER) != null)) {
120 String conversionFields = request.getParameter(KRADConstants.CONVERSION_FIELDS_PARAMETER);
121 setFieldConversions(KRADUtils.convertStringParameterToMap(conversionFields));
122 }
123 }
124
125
126
127
128
129
130 public Lookupable getLookupable() {
131 if (getViewHelperService() != null) {
132 return (Lookupable) getViewHelperService();
133 }
134
135 return null;
136 }
137
138
139
140
141
142
143
144
145
146
147 public String getDataObjectClassName() {
148 return this.dataObjectClassName;
149 }
150
151
152
153
154
155
156 public void setDataObjectClassName(String dataObjectClassName) {
157 this.dataObjectClassName = dataObjectClassName;
158 }
159
160
161
162
163
164
165
166
167
168 public boolean isMultipleValuesSelect() {
169 return multipleValuesSelect;
170 }
171
172
173
174
175 public void setMultipleValuesSelect(boolean multipleValuesSelect) {
176 this.multipleValuesSelect = multipleValuesSelect;
177 }
178
179
180
181
182
183
184
185
186
187 public boolean isRedirectedLookup() {
188 return redirectedLookup;
189 }
190
191
192
193
194 public void setRedirectedLookup(boolean redirectedLookup) {
195 this.redirectedLookup = redirectedLookup;
196 }
197
198
199
200
201
202
203
204
205 public boolean isReturnByScript() {
206 return returnByScript;
207 }
208
209
210
211
212 public void setReturnByScript(boolean returnByScript) {
213 this.returnByScript = returnByScript;
214 }
215
216
217
218
219
220
221
222
223
224
225 public String getReturnTarget() {
226 return returnTarget;
227 }
228
229
230
231
232 public void setReturnTarget(String returnTarget) {
233 this.returnTarget = returnTarget;
234 }
235
236
237
238
239
240
241
242 public String getLookupCollectionName() {
243 return lookupCollectionName;
244 }
245
246
247
248
249 public void setLookupCollectionName(String lookupCollectionName) {
250 this.lookupCollectionName = lookupCollectionName;
251 }
252
253 public String getLookupCollectionId() {
254 return lookupCollectionId;
255 }
256
257 public void setLookupCollectionId(String lookupCollectionId) {
258 this.lookupCollectionId = lookupCollectionId;
259 }
260
261
262
263
264
265
266
267 public String getReferencesToRefresh() {
268 return referencesToRefresh;
269 }
270
271
272
273
274 public void setReferencesToRefresh(String referencesToRefresh) {
275 this.referencesToRefresh = referencesToRefresh;
276 }
277
278
279
280
281
282
283
284
285
286
287 public String getQuickfinderId() {
288 return quickfinderId;
289 }
290
291
292
293
294 public void setQuickfinderId(String quickfinderId) {
295 this.quickfinderId = quickfinderId;
296 }
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317 public Map<String, String> getFieldConversions() {
318 return this.fieldConversions;
319 }
320
321
322
323
324 public void setFieldConversions(Map<String, String> fieldConversions) {
325 this.fieldConversions = fieldConversions;
326 }
327
328
329
330
331
332
333
334 public List<String> getMultiValueReturnFields() {
335 return multiValueReturnFields;
336 }
337
338
339
340
341 public void setMultiValueReturnFields(List<String> multiValueReturnFields) {
342 this.multiValueReturnFields = multiValueReturnFields;
343 }
344
345
346
347
348
349
350
351
352
353
354
355
356 public Map<String, String> getLookupCriteria() {
357 return this.lookupCriteria;
358 }
359
360
361
362
363 public void setLookupCriteria(Map<String, String> lookupCriteria) {
364 this.lookupCriteria = lookupCriteria;
365 }
366
367
368
369
370
371
372
373
374
375
376 public Collection<?> getLookupResults() {
377 return this.lookupResults;
378 }
379
380
381
382
383 public void setLookupResults(Collection<?> lookupResults) {
384 this.lookupResults = lookupResults;
385 }
386
387 public boolean isDisplayResults() {
388 return displayResults;
389 }
390
391 public void setDisplayResults(boolean displayResults) {
392 this.displayResults = displayResults;
393 }
394 }