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.validator.ErrorReport;
22 import org.kuali.rice.krad.datadictionary.validator.ValidationTrace;
23 import org.kuali.rice.krad.datadictionary.validator.Validator;
24 import org.kuali.rice.krad.uif.component.Component;
25 import org.kuali.rice.krad.uif.component.ComponentSecurity;
26 import org.kuali.rice.krad.uif.element.Action;
27 import org.kuali.rice.krad.uif.element.Image;
28 import org.kuali.rice.krad.uif.view.View;
29
30 import java.util.ArrayList;
31 import java.util.List;
32 import java.util.Map;
33
34
35
36
37
38
39 @BeanTag(name = "actionField-bean", parent = "Uif-ActionField")
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(View view, Object model, Component parent) {
59 super.performFinalize(view, 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 public void addActionParameter(String parameterName, String parameterValue) {
193 action.addActionParameter(parameterName, parameterValue);
194 }
195
196
197
198
199 public String getActionParameter(String parameterName) {
200 return action.getActionParameter(parameterName);
201 }
202
203
204
205
206 public void setComponentSecurity(ComponentSecurity componentSecurity) {
207 action.setComponentSecurity(componentSecurity);
208 }
209
210
211
212
213 @BeanTagAttribute(name = "jumpToIdAfterSubmit")
214 public String getJumpToIdAfterSubmit() {
215 return action.getJumpToIdAfterSubmit();
216 }
217
218
219
220
221
222 public void setJumpToIdAfterSubmit(String jumpToIdAfterSubmit) {
223 action.setJumpToIdAfterSubmit(jumpToIdAfterSubmit);
224 }
225
226
227
228
229 @BeanTagAttribute(name = "jumpToNameAfterSubmit")
230 public String getJumpToNameAfterSubmit() {
231 return action.getJumpToNameAfterSubmit();
232 }
233
234
235
236
237 public void setJumpToNameAfterSubmit(String jumpToNameAfterSubmit) {
238 action.setJumpToNameAfterSubmit(jumpToNameAfterSubmit);
239 }
240
241
242
243
244 @BeanTagAttribute(name = "focusOnIdAfterSubmit")
245 public String getFocusOnIdAfterSubmit() {
246 return action.getFocusOnIdAfterSubmit();
247 }
248
249
250
251
252 public void setFocusOnIdAfterSubmit(String focusOnAfterSubmit) {
253 action.setFocusOnIdAfterSubmit(focusOnAfterSubmit);
254 }
255
256
257
258
259 @BeanTagAttribute(name = "performClientSideValidation")
260 public boolean isPerformClientSideValidation() {
261 return action.isPerformClientSideValidation();
262 }
263
264
265
266
267 public void setPerformClientSideValidation(boolean clientSideValidate) {
268 action.setPerformClientSideValidation(clientSideValidate);
269 }
270
271
272
273
274 @BeanTagAttribute(name = "actionScript")
275 public String getActionScript() {
276 return action.getActionScript();
277 }
278
279
280
281
282 public void setActionScript(String actionScript) {
283 action.setActionScript(actionScript);
284 }
285
286
287
288
289 @BeanTagAttribute(name = "performDirtyValidation")
290 public boolean isPerformDirtyValidation() {
291 return action.isPerformDirtyValidation();
292 }
293
294
295
296
297 public void setPerformDirtyValidation(boolean blockValidateDirty) {
298 action.setPerformDirtyValidation(blockValidateDirty);
299 }
300
301
302
303
304 @BeanTagAttribute(name = "disabled")
305 public boolean isDisabled() {
306 return action.isDisabled();
307 }
308
309
310
311
312 public void setDisabled(boolean disabled) {
313 action.setDisabled(disabled);
314 }
315
316
317
318
319 @BeanTagAttribute(name = "disabledReason")
320 public String getDisabledReason() {
321 return action.getDisabledReason();
322 }
323
324
325
326
327 public void setDisabledReason(String disabledReason) {
328 action.setDisabledReason(disabledReason);
329 }
330
331
332
333
334 @BeanTagAttribute(name = "actionImagePlacement")
335 public String getActionImagePlacement() {
336 return action.getActionImagePlacement();
337 }
338
339
340
341
342 public void setActionImagePlacement(String actionImageLocation) {
343 action.setActionImagePlacement(actionImageLocation);
344 }
345
346
347
348
349 @BeanTagAttribute(name = "preSubmitCall")
350 public String getPreSubmitCall() {
351 return action.getPreSubmitCall();
352 }
353
354
355
356
357 public void setPreSubmitCall(String preSubmitCall) {
358 action.setPreSubmitCall(preSubmitCall);
359 }
360
361
362
363
364 @BeanTagAttribute(name = "ajaxSubmit")
365 public boolean isAjaxSubmit() {
366 return action.isAjaxSubmit();
367 }
368
369
370
371
372 public void setAjaxSubmit(boolean ajaxSubmit) {
373 action.setAjaxSubmit(ajaxSubmit);
374 }
375
376
377
378
379 @BeanTagAttribute(name = "successCallback")
380 public String getSuccessCallback() {
381 return action.getSuccessCallback();
382 }
383
384
385
386
387
388 public void setSuccessCallback(String successCallback) {
389 action.setSuccessCallback(successCallback);
390 }
391
392
393
394
395 @BeanTagAttribute(name = "errorCallback")
396 public String getErrorCallback() {
397 return action.getErrorCallback();
398 }
399
400
401
402
403
404
405 public void setErrorCallback(String errorCallback) {
406 action.setErrorCallback(errorCallback);
407 }
408
409
410
411
412 @Override
413 public void completeValidation(ValidationTrace tracer) {
414 ArrayList<ErrorReport> reports = new ArrayList<ErrorReport>();
415 tracer.addBean(this);
416
417
418 if (getAction() == null) {
419 if (Validator.checkExpressions(this, "action")) {
420 String currentValues[] = {"action =" + getAction()};
421 tracer.createWarning("Action should not be null", currentValues);
422 }
423 }
424
425
426 if (getLabel() == null) {
427 if (Validator.checkExpressions(this, "label")) {
428 String currentValues[] = {"label =" + getLabel(), "action =" + getAction()};
429 tracer.createWarning("Label is null, action should be used instead", currentValues);
430 }
431 }
432
433 super.completeValidation(tracer.getCopy());
434 }
435 }