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.uif.UifConstants;
20 import org.kuali.rice.krad.uif.component.Component;
21 import org.kuali.rice.krad.uif.view.View;
22
23
24
25
26
27
28 public class AjaxActionField extends ActionField {
29 private static final long serialVersionUID = -2831173647391138870L;
30
31 private String refreshId;
32 private String refreshPropertyName;
33
34 public AjaxActionField() {
35 super();
36 }
37
38
39
40
41
42
43
44
45
46
47
48
49 @Override
50 public void performFinalize(View view, Object model, Component parent) {
51 Component refreshComponent = null;
52
53
54
55 if (StringUtils.isNotBlank(refreshPropertyName)) {
56 if (refreshPropertyName.startsWith(UifConstants.NO_BIND_ADJUST_PREFIX)) {
57 refreshPropertyName = StringUtils.removeStart(refreshPropertyName, UifConstants.NO_BIND_ADJUST_PREFIX);
58 } else if (StringUtils.isNotBlank(view.getDefaultBindingObjectPath())) {
59 refreshPropertyName = view.getDefaultBindingObjectPath() + "." + refreshPropertyName;
60 }
61
62 DataField dataField = view.getViewIndex().getDataFieldByPath(refreshPropertyName);
63 if (dataField != null) {
64 refreshComponent = dataField;
65 }
66 }
67 else if (StringUtils.isNotBlank(refreshId)) {
68 Component component = view.getViewIndex().getComponentById(refreshId);
69 if (component != null) {
70 refreshComponent = component;
71 }
72 }
73
74 String actionScript = "";
75 if (refreshComponent != null) {
76 refreshComponent.setRefreshedByAction(true);
77
78 Component initialComponent = view.getViewIndex().getInitialComponentStates().get(
79 refreshComponent.getFactoryId());
80 if (initialComponent != null) {
81 initialComponent.setRefreshedByAction(true);
82 view.getViewIndex().getInitialComponentStates().put(refreshComponent.getFactoryId(), initialComponent);
83 }
84
85
86 actionScript = "retrieveComponent('" + refreshComponent.getId() + "','" + refreshComponent.getFactoryId()
87 + "','" + getMethodToCall() + "');";
88 }
89 else {
90
91 actionScript = "submitForm();";
92 }
93
94
95 if (StringUtils.isNotBlank(getClientSideJs())) {
96 actionScript = getClientSideJs() + actionScript;
97 }
98 setClientSideJs(actionScript);
99
100 super.performFinalize(view, model, parent);
101 }
102
103
104
105
106
107
108
109
110
111
112
113 public String getRefreshId() {
114 return refreshId;
115 }
116
117
118
119
120
121
122 public void setRefreshId(String refreshId) {
123 this.refreshId = refreshId;
124 }
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141 public String getRefreshPropertyName() {
142 return refreshPropertyName;
143 }
144
145
146
147
148
149
150 public void setRefreshPropertyName(String refreshPropertyName) {
151 this.refreshPropertyName = refreshPropertyName;
152 }
153 }