1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.uif.field;
17
18 import java.util.ArrayList;
19 import java.util.List;
20 import java.util.Map;
21
22 import org.apache.commons.lang.StringUtils;
23 import org.kuali.rice.krad.datadictionary.parse.BeanTag;
24 import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
25 import org.kuali.rice.krad.datadictionary.parse.BeanTags;
26 import org.kuali.rice.krad.datadictionary.validator.ErrorReport;
27 import org.kuali.rice.krad.datadictionary.validator.ValidationTrace;
28 import org.kuali.rice.krad.datadictionary.validator.Validator;
29 import org.kuali.rice.krad.uif.component.Component;
30 import org.kuali.rice.krad.uif.element.Action;
31 import org.kuali.rice.krad.uif.element.Image;
32
33
34
35
36
37
38 @BeanTags({@BeanTag(name = "actionField-bean", parent = "Uif-ActionField"),
39 @BeanTag(name = "actionLinkField-bean", parent = "Uif-ActionLinkField")})
40 public class ActionField extends FieldBase {
41 private static final long serialVersionUID = -8495752159848603102L;
42
43 private Action action;
44
45 public ActionField() {
46 action = new Action();
47 }
48
49
50
51
52
53
54
55
56
57 @Override
58 public void performFinalize(Object model, Component parent) {
59 super.performFinalize(model, parent);
60
61
62 if (this.getFieldLabel() != null && this.getAction() != null && StringUtils.isNotBlank(
63 this.getAction().getId())) {
64 this.getFieldLabel().setLabelForComponentId(this.getAction().getId());
65 }
66 }
67
68
69
70
71 @Override
72 public List<Component> getComponentsForLifecycle() {
73 List<Component> components = super.getComponentsForLifecycle();
74
75 components.add(action);
76
77 return components;
78 }
79
80
81
82
83
84
85 @BeanTagAttribute(name = "action", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
86 public Action getAction() {
87 return action;
88 }
89
90
91
92
93
94
95 public void setAction(Action action) {
96 this.action = action;
97 }
98
99
100
101
102 @BeanTagAttribute(name = "methodToCall")
103 public String getMethodToCall() {
104 return action.getMethodToCall();
105 }
106
107
108
109
110 public void setMethodToCall(String methodToCall) {
111 action.setMethodToCall(methodToCall);
112 }
113
114
115
116
117 @BeanTagAttribute(name = "actionLabel")
118 public String getActionLabel() {
119 return action.getActionLabel();
120 }
121
122
123
124
125 public void setActionLabel(String actionLabel) {
126 action.setActionLabel(actionLabel);
127 }
128
129
130
131
132 @BeanTagAttribute(name = "actionImage", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
133 public Image getActionImage() {
134 return action.getActionImage();
135 }
136
137
138
139
140 public void setActionImage(Image actionImage) {
141 action.setActionImage(actionImage);
142 }
143
144
145
146
147 @BeanTagAttribute(name = "navigateToPageId")
148 public String getNavigateToPageId() {
149 return action.getNavigateToPageId();
150 }
151
152
153
154
155 public void setNavigateToPageId(String navigateToPageId) {
156 action.setNavigateToPageId(navigateToPageId);
157 }
158
159
160
161
162 @BeanTagAttribute(name = "actionEvent")
163 public String getActionEvent() {
164 return action.getActionEvent();
165 }
166
167
168
169
170 public void setActionEvent(String actionEvent) {
171 action.setActionEvent(actionEvent);
172 }
173
174
175
176
177 @BeanTagAttribute(name = "actionParameters", type = BeanTagAttribute.AttributeType.MAPVALUE)
178 public Map<String, String> getActionParameters() {
179 return action.getActionParameters();
180 }
181
182
183
184
185 public void setActionParameters(Map<String, String> actionParameters) {
186 action.setActionParameters(actionParameters);
187 }
188
189
190
191
192 @BeanTagAttribute(name = "additionalSubmitData", type = BeanTagAttribute.AttributeType.MAPVALUE)
193 public Map<String, String> getAdditionalSubmitData() {
194 return action.getAdditionalSubmitData();
195 }
196
197
198
199
200 public void setAdditionalSubmitData(Map<String, String> additionalSubmitData) {
201 action.setAdditionalSubmitData(additionalSubmitData);
202 }
203
204
205
206
207 public void addActionParameter(String parameterName, String parameterValue) {
208 action.addActionParameter(parameterName, parameterValue);
209 }
210
211
212
213
214 public String getActionParameter(String parameterName) {
215 return action.getActionParameter(parameterName);
216 }
217
218
219
220
221 @BeanTagAttribute(name = "jumpToIdAfterSubmit")
222 public String getJumpToIdAfterSubmit() {
223 return action.getJumpToIdAfterSubmit();
224 }
225
226
227
228
229
230 public void setJumpToIdAfterSubmit(String jumpToIdAfterSubmit) {
231 action.setJumpToIdAfterSubmit(jumpToIdAfterSubmit);
232 }
233
234
235
236
237 @BeanTagAttribute(name = "jumpToNameAfterSubmit")
238 public String getJumpToNameAfterSubmit() {
239 return action.getJumpToNameAfterSubmit();
240 }
241
242
243
244
245 public void setJumpToNameAfterSubmit(String jumpToNameAfterSubmit) {
246 action.setJumpToNameAfterSubmit(jumpToNameAfterSubmit);
247 }
248
249
250
251
252 @BeanTagAttribute(name = "focusOnIdAfterSubmit")
253 public String getFocusOnIdAfterSubmit() {
254 return action.getFocusOnIdAfterSubmit();
255 }
256
257
258
259
260 public void setFocusOnIdAfterSubmit(String focusOnAfterSubmit) {
261 action.setFocusOnIdAfterSubmit(focusOnAfterSubmit);
262 }
263
264
265
266
267 @BeanTagAttribute(name = "performClientSideValidation")
268 public boolean isPerformClientSideValidation() {
269 return action.isPerformClientSideValidation();
270 }
271
272
273
274
275 public void setPerformClientSideValidation(boolean clientSideValidate) {
276 action.setPerformClientSideValidation(clientSideValidate);
277 }
278
279
280
281
282 @BeanTagAttribute(name = "actionScript")
283 public String getActionScript() {
284 return action.getActionScript();
285 }
286
287
288
289
290 public void setActionScript(String actionScript) {
291 action.setActionScript(actionScript);
292 }
293
294
295
296
297 @BeanTagAttribute(name = "performDirtyValidation")
298 public boolean isPerformDirtyValidation() {
299 return action.isPerformDirtyValidation();
300 }
301
302
303
304
305 public void setPerformDirtyValidation(boolean blockValidateDirty) {
306 action.setPerformDirtyValidation(blockValidateDirty);
307 }
308
309
310
311
312 @BeanTagAttribute(name = "disabled")
313 public boolean isDisabled() {
314 return action.isDisabled();
315 }
316
317
318
319
320 public void setDisabled(boolean disabled) {
321 action.setDisabled(disabled);
322 }
323
324
325
326
327 @BeanTagAttribute(name = "disabledReason")
328 public String getDisabledReason() {
329 return action.getDisabledReason();
330 }
331
332
333
334
335 public void setDisabledReason(String disabledReason) {
336 action.setDisabledReason(disabledReason);
337 }
338
339
340
341
342 @BeanTagAttribute(name = "actionImagePlacement")
343 public String getActionImagePlacement() {
344 return action.getActionImagePlacement();
345 }
346
347
348
349
350 public void setActionImagePlacement(String actionImageLocation) {
351 action.setActionImagePlacement(actionImageLocation);
352 }
353
354
355
356
357 @BeanTagAttribute(name = "preSubmitCall")
358 public String getPreSubmitCall() {
359 return action.getPreSubmitCall();
360 }
361
362
363
364
365 public void setPreSubmitCall(String preSubmitCall) {
366 action.setPreSubmitCall(preSubmitCall);
367 }
368
369
370
371
372 @BeanTagAttribute(name = "ajaxSubmit")
373 public boolean isAjaxSubmit() {
374 return action.isAjaxSubmit();
375 }
376
377
378
379
380 public void setAjaxSubmit(boolean ajaxSubmit) {
381 action.setAjaxSubmit(ajaxSubmit);
382 }
383
384
385
386
387 @BeanTagAttribute(name = "successCallback")
388 public String getSuccessCallback() {
389 return action.getSuccessCallback();
390 }
391
392
393
394
395
396 public void setSuccessCallback(String successCallback) {
397 action.setSuccessCallback(successCallback);
398 }
399
400
401
402
403 @BeanTagAttribute(name = "errorCallback")
404 public String getErrorCallback() {
405 return action.getErrorCallback();
406 }
407
408
409
410
411
412 public void setErrorCallback(String errorCallback) {
413 action.setErrorCallback(errorCallback);
414 }
415
416
417
418
419 @BeanTagAttribute(name = "refreshId")
420 public String getRefreshId() {
421 return action.getRefreshId();
422 }
423
424
425
426
427 public void setRefreshId(String refreshId) {
428 action.setRefreshId(refreshId);
429 }
430
431
432
433
434 @BeanTagAttribute(name = "disableBlocking")
435 public boolean isDisableBlocking() {
436 return action.isDisableBlocking();
437 }
438
439
440
441
442 public void setDisableBlocking(boolean disableBlocking) {
443 action.setDisableBlocking(disableBlocking);
444 }
445
446
447
448
449 @Override
450 protected <T> void copyProperties(T component) {
451 super.copyProperties(component);
452
453 ActionField actionFieldCopy = (ActionField) component;
454
455 if (this.action != null) {
456 actionFieldCopy.setAction((Action)this.action.copy());
457 }
458 }
459
460
461
462
463 @Override
464 public void completeValidation(ValidationTrace tracer) {
465 ArrayList<ErrorReport> reports = new ArrayList<ErrorReport>();
466 tracer.addBean(this);
467
468
469 if (getAction() == null) {
470 if (Validator.checkExpressions(this, "action")) {
471 String currentValues[] = {"action =" + getAction()};
472 tracer.createWarning("Action should not be null", currentValues);
473 }
474 }
475
476
477 if (getLabel() == null) {
478 if (Validator.checkExpressions(this, "label")) {
479 String currentValues[] = {"label =" + getLabel(), "action =" + getAction()};
480 tracer.createWarning("Label is null, action should be used instead", currentValues);
481 }
482 }
483
484 super.completeValidation(tracer.getCopy());
485 }
486 }