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