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 @BeanTagAttribute(name = "jumpToIdAfterSubmit")
224 public String getJumpToIdAfterSubmit() {
225 return action.getJumpToIdAfterSubmit();
226 }
227
228
229
230
231
232 public void setJumpToIdAfterSubmit(String jumpToIdAfterSubmit) {
233 action.setJumpToIdAfterSubmit(jumpToIdAfterSubmit);
234 }
235
236
237
238
239 @BeanTagAttribute(name = "jumpToNameAfterSubmit")
240 public String getJumpToNameAfterSubmit() {
241 return action.getJumpToNameAfterSubmit();
242 }
243
244
245
246
247 public void setJumpToNameAfterSubmit(String jumpToNameAfterSubmit) {
248 action.setJumpToNameAfterSubmit(jumpToNameAfterSubmit);
249 }
250
251
252
253
254 @BeanTagAttribute(name = "focusOnIdAfterSubmit")
255 public String getFocusOnIdAfterSubmit() {
256 return action.getFocusOnIdAfterSubmit();
257 }
258
259
260
261
262 public void setFocusOnIdAfterSubmit(String focusOnAfterSubmit) {
263 action.setFocusOnIdAfterSubmit(focusOnAfterSubmit);
264 }
265
266
267
268
269 @BeanTagAttribute(name = "performClientSideValidation")
270 public boolean isPerformClientSideValidation() {
271 return action.isPerformClientSideValidation();
272 }
273
274
275
276
277 public void setPerformClientSideValidation(boolean clientSideValidate) {
278 action.setPerformClientSideValidation(clientSideValidate);
279 }
280
281
282
283
284 @BeanTagAttribute(name = "actionScript")
285 public String getActionScript() {
286 return action.getActionScript();
287 }
288
289
290
291
292 public void setActionScript(String actionScript) {
293 action.setActionScript(actionScript);
294 }
295
296
297
298
299 @BeanTagAttribute(name = "performDirtyValidation")
300 public boolean isPerformDirtyValidation() {
301 return action.isPerformDirtyValidation();
302 }
303
304
305
306
307 public void setPerformDirtyValidation(boolean blockValidateDirty) {
308 action.setPerformDirtyValidation(blockValidateDirty);
309 }
310
311
312
313
314 @BeanTagAttribute(name = "disabled")
315 public boolean isDisabled() {
316 return action.isDisabled();
317 }
318
319
320
321
322 public void setDisabled(boolean disabled) {
323 action.setDisabled(disabled);
324 }
325
326
327
328
329 @BeanTagAttribute(name = "disabledReason")
330 public String getDisabledReason() {
331 return action.getDisabledReason();
332 }
333
334
335
336
337 public void setDisabledReason(String disabledReason) {
338 action.setDisabledReason(disabledReason);
339 }
340
341
342
343
344 @BeanTagAttribute(name = "actionImagePlacement")
345 public String getActionImagePlacement() {
346 return action.getActionImagePlacement();
347 }
348
349
350
351
352 public void setActionImagePlacement(String actionImageLocation) {
353 action.setActionImagePlacement(actionImageLocation);
354 }
355
356
357
358
359 @BeanTagAttribute(name = "preSubmitCall")
360 public String getPreSubmitCall() {
361 return action.getPreSubmitCall();
362 }
363
364
365
366
367 public void setPreSubmitCall(String preSubmitCall) {
368 action.setPreSubmitCall(preSubmitCall);
369 }
370
371
372
373
374 @BeanTagAttribute(name = "ajaxSubmit")
375 public boolean isAjaxSubmit() {
376 return action.isAjaxSubmit();
377 }
378
379
380
381
382 public void setAjaxSubmit(boolean ajaxSubmit) {
383 action.setAjaxSubmit(ajaxSubmit);
384 }
385
386
387
388
389 @BeanTagAttribute(name = "successCallback")
390 public String getSuccessCallback() {
391 return action.getSuccessCallback();
392 }
393
394
395
396
397
398 public void setSuccessCallback(String successCallback) {
399 action.setSuccessCallback(successCallback);
400 }
401
402
403
404
405 @BeanTagAttribute(name = "errorCallback")
406 public String getErrorCallback() {
407 return action.getErrorCallback();
408 }
409
410
411
412
413
414 public void setErrorCallback(String errorCallback) {
415 action.setErrorCallback(errorCallback);
416 }
417
418
419
420
421 @BeanTagAttribute(name = "refreshId")
422 public String getRefreshId() {
423 return action.getRefreshId();
424 }
425
426
427
428
429 public void setRefreshId(String refreshId) {
430 action.setRefreshId(refreshId);
431 }
432
433
434
435
436 @BeanTagAttribute(name = "disableBlocking")
437 public boolean isDisableBlocking() {
438 return action.isDisableBlocking();
439 }
440
441
442
443
444 public void setDisableBlocking(boolean disableBlocking) {
445 action.setDisableBlocking(disableBlocking);
446 }
447
448
449
450
451 @Override
452 public void completeValidation(ValidationTrace tracer) {
453 ArrayList<ErrorReport> reports = new ArrayList<ErrorReport>();
454 tracer.addBean(this);
455
456
457 if (getAction() == null) {
458 if (Validator.checkExpressions(this, "action")) {
459 String currentValues[] = {"action =" + getAction()};
460 tracer.createWarning("Action should not be null", currentValues);
461 }
462 }
463
464
465 if (getLabel() == null) {
466 if (Validator.checkExpressions(this, "label")) {
467 String currentValues[] = {"label =" + getLabel(), "action =" + getAction()};
468 tracer.createWarning("Label is null, action should be used instead", currentValues);
469 }
470 }
471
472 super.completeValidation(tracer.getCopy());
473 }
474
475
476
477
478 @Override
479 protected <T> void copyProperties(T component) {
480 super.copyProperties(component);
481 ActionField actionFieldCopy = (ActionField) component;
482
483 if (this.action != null) {
484 actionFieldCopy.setAction((Action)this.action.copy());
485 }
486 }
487 }