1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.uif.container;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.krad.uif.component.Component;
20 import org.kuali.rice.krad.uif.component.DataBinding;
21 import org.kuali.rice.krad.uif.component.ComponentSecurity;
22 import org.kuali.rice.krad.uif.field.Field;
23 import org.kuali.rice.krad.uif.field.FieldGroup;
24 import org.kuali.rice.krad.uif.view.View;
25 import org.kuali.rice.krad.uif.widget.Disclosure;
26
27 import java.util.ArrayList;
28 import java.util.HashSet;
29 import java.util.List;
30 import java.util.Set;
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52 public class Group extends ContainerBase {
53 private static final long serialVersionUID = 7953641325356535509L;
54
55 private String fieldBindByNamePrefix;
56 private String fieldBindingObjectPath;
57
58 private Disclosure disclosure;
59
60 private List<? extends Component> items;
61
62
63
64
65 public Group() {
66 items = new ArrayList<Component>();
67 }
68
69
70
71
72
73
74
75
76
77
78
79 @Override
80 public void performInitialization(View view, Object model) {
81 super.performInitialization(view, model);
82
83 for (Component component : getItems()) {
84
85
86 if (component instanceof DataBinding) {
87 DataBinding dataBinding = (DataBinding) component;
88
89 if (StringUtils.isNotBlank(getFieldBindByNamePrefix())) {
90 String bindByNamePrefixToSet = getFieldBindByNamePrefix();
91
92 if (StringUtils.isNotBlank(dataBinding.getBindingInfo().getBindByNamePrefix())) {
93 bindByNamePrefixToSet += "." + dataBinding.getBindingInfo().getBindByNamePrefix();
94 }
95 dataBinding.getBindingInfo().setBindByNamePrefix(bindByNamePrefixToSet);
96 }
97
98 if (StringUtils.isNotBlank(fieldBindingObjectPath) &&
99 StringUtils.isBlank(dataBinding.getBindingInfo().getBindingObjectPath())) {
100 dataBinding.getBindingInfo().setBindingObjectPath(fieldBindingObjectPath);
101 }
102 }
103
104 else if (component instanceof FieldGroup) {
105 FieldGroup fieldGroup = (FieldGroup) component;
106
107 if (fieldGroup.getGroup() != null) {
108 if (StringUtils.isBlank(fieldGroup.getGroup().getFieldBindByNamePrefix())) {
109 fieldGroup.getGroup().setFieldBindByNamePrefix(fieldBindByNamePrefix);
110 }
111 if (StringUtils.isBlank(fieldGroup.getGroup().getFieldBindingObjectPath())) {
112 fieldGroup.getGroup().setFieldBindingObjectPath(fieldBindingObjectPath);
113 }
114 }
115 } else if (component instanceof Group) {
116 Group subGroup = (Group) component;
117 if (StringUtils.isNotBlank(getFieldBindByNamePrefix())) {
118 if (StringUtils.isNotBlank(subGroup.getFieldBindByNamePrefix())) {
119 subGroup.setFieldBindByNamePrefix(
120 getFieldBindByNamePrefix() + "." + subGroup.getFieldBindByNamePrefix());
121 } else {
122 subGroup.setFieldBindByNamePrefix(getFieldBindByNamePrefix());
123 }
124 }
125 if (StringUtils.isNotBlank(getFieldBindingObjectPath())) {
126 if (StringUtils.isNotBlank(subGroup.getFieldBindingObjectPath())) {
127 subGroup.setFieldBindingObjectPath(
128 getFieldBindingObjectPath() + "." + subGroup.getFieldBindingObjectPath());
129 } else {
130 subGroup.setFieldBindingObjectPath(getFieldBindingObjectPath());
131 }
132 }
133 }
134 }
135 }
136
137
138
139
140 @Override
141 public List<Component> getComponentsForLifecycle() {
142 List<Component> components = super.getComponentsForLifecycle();
143
144 components.add(disclosure);
145
146 return components;
147 }
148
149
150
151
152 @Override
153 public Set<Class<? extends Component>> getSupportedComponents() {
154 Set<Class<? extends Component>> supportedComponents = new HashSet<Class<? extends Component>>();
155 supportedComponents.add(Field.class);
156 supportedComponents.add(Group.class);
157
158 return supportedComponents;
159 }
160
161
162
163
164 @Override
165 public final String getComponentTypeName() {
166 return "group";
167 }
168
169
170
171
172
173
174
175
176
177
178
179
180
181 public String getFieldBindByNamePrefix() {
182 return this.fieldBindByNamePrefix;
183 }
184
185
186
187
188
189
190 public void setFieldBindByNamePrefix(String fieldBindByNamePrefix) {
191 this.fieldBindByNamePrefix = fieldBindByNamePrefix;
192 }
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209 public String getFieldBindingObjectPath() {
210 return this.fieldBindingObjectPath;
211 }
212
213
214
215
216
217
218 public void setFieldBindingObjectPath(String fieldBindingObjectPath) {
219 this.fieldBindingObjectPath = fieldBindingObjectPath;
220 }
221
222
223
224
225
226
227
228 public Disclosure getDisclosure() {
229 return this.disclosure;
230 }
231
232
233
234
235
236
237 public void setDisclosure(Disclosure disclosure) {
238 this.disclosure = disclosure;
239 }
240
241
242
243
244 @Override
245 public List<? extends Component> getItems() {
246 return this.items;
247 }
248
249
250
251
252
253
254 @Override
255 public void setItems(List<? extends Component> items) {
256 this.items = items;
257 }
258
259 }