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
57 if (refreshPropertyName.startsWith(UifConstants.NO_BIND_ADJUST_PREFIX)) {
58 refreshPropertyName = StringUtils.removeStart(refreshPropertyName, UifConstants.NO_BIND_ADJUST_PREFIX);
59 } else if (StringUtils.isNotBlank(view.getDefaultBindingObjectPath())) {
60 refreshPropertyName = view.getDefaultBindingObjectPath() + "." + refreshPropertyName;
61 }
62
63 DataField dataField = view.getViewIndex().getDataFieldByPath(refreshPropertyName);
64 if (dataField != null) {
65 refreshComponent = dataField;
66 }
67 }
68 else if (StringUtils.isNotBlank(refreshId)) {
69 Component component = view.getViewIndex().getComponentById(refreshId);
70 if (component != null) {
71 refreshComponent = component;
72 }
73 }
74
75 String actionScript = "";
76 if (refreshComponent != null) {
77 refreshComponent.setRefreshedByAction(true);
78
79 Component initialComponent = view.getViewIndex().getInitialComponentStates().get(
80 refreshComponent.getFactoryId());
81 if (initialComponent != null) {
82 initialComponent.setRefreshedByAction(true);
83 view.getViewIndex().getInitialComponentStates().put(refreshComponent.getFactoryId(), initialComponent);
84 }
85
86
87 actionScript = "retrieveComponent('" + refreshComponent.getId() + "','" + refreshComponent.getFactoryId()
88 + "','" + getMethodToCall() + "');";
89 }
90 else {
91
92 actionScript = "submitForm();";
93 }
94
95
96 if (StringUtils.isNotBlank(getClientSideJs())) {
97 actionScript = getClientSideJs() + actionScript;
98 }
99 setClientSideJs(actionScript);
100
101 super.performFinalize(view, model, parent);
102 }
103
104
105
106
107
108
109
110
111
112
113
114 public String getRefreshId() {
115 return refreshId;
116 }
117
118
119
120
121
122
123 public void setRefreshId(String refreshId) {
124 this.refreshId = refreshId;
125 }
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142 public String getRefreshPropertyName() {
143 return refreshPropertyName;
144 }
145
146
147
148
149
150
151 public void setRefreshPropertyName(String refreshPropertyName) {
152 this.refreshPropertyName = refreshPropertyName;
153 }
154 }