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 com.google.common.collect.Lists;
19 import org.apache.commons.lang.StringUtils;
20 import org.kuali.rice.krad.datadictionary.parse.BeanTag;
21 import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
22 import org.kuali.rice.krad.datadictionary.parse.BeanTags;
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.DataBinding;
27 import org.kuali.rice.krad.uif.field.Field;
28 import org.kuali.rice.krad.uif.field.FieldGroup;
29 import org.kuali.rice.krad.uif.view.View;
30 import org.kuali.rice.krad.uif.widget.Disclosure;
31 import org.kuali.rice.krad.uif.widget.Scrollpane;
32
33 import java.util.ArrayList;
34 import java.util.HashSet;
35 import java.util.List;
36 import java.util.Set;
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58 @BeanTags({@BeanTag(name = "group-bean", parent = "Uif-GroupBase"),
59 @BeanTag(name = "boxGroupBase-bean", parent = "Uif-BoxGroupBase"),
60 @BeanTag(name = "verticalBoxGroup-bean", parent = "Uif-VerticalBoxGroup"),
61 @BeanTag(name = "verticalBoxSection-bean", parent = "Uif-VerticalBoxSection"),
62 @BeanTag(name = "verticalBoxSubSection-bean", parent = "Uif-VerticalBoxSubSection"),
63 @BeanTag(name = "disclosure-verticalBoxSection-bean", parent = "Uif-Disclosure-VerticalBoxSection"),
64 @BeanTag(name = "disclosure-verticalBoxSubSection-bean", parent = "Uif-Disclosure-VerticalBoxSubSection"),
65 @BeanTag(name = "horizontalBoxGroup-bean", parent = "Uif-HorizontalBoxGroup"),
66 @BeanTag(name = "horizontalBoxSection-bean", parent = "Uif-HorizontalBoxSection"),
67 @BeanTag(name = "horizontalBoxSubSection-bean", parent = "Uif-HorizontalBoxSubSection"),
68 @BeanTag(name = "disclosure-horizontalBoxSection-bean", parent = "Uif-Disclosure-HorizontalBoxSection"),
69 @BeanTag(name = "disclosure-horizontalBoxSubSection-bean", parent = "Uif-Disclosure-HorizontalBoxSubSection"),
70 @BeanTag(name = "gridGroup-bean", parent = "Uif-GridGroup"),
71 @BeanTag(name = "gridSection-bean", parent = "Uif-GridSection"),
72 @BeanTag(name = "gridSubSection-bean", parent = "Uif-GridSubSection"),
73 @BeanTag(name = "disclosure-gridSection-bean", parent = "Uif-Disclosure-GridSection"),
74 @BeanTag(name = "fixedCssGridGroup-bean", parent = "Uif-FixedCssGridGroup"),
75 @BeanTag(name = "fixedCssGridSection-bean", parent = "Uif-FixedCssGridSection"),
76 @BeanTag(name = "fixedCssGridSubSection-bean", parent = "Uif-FixedCssGridSubSection"),
77 @BeanTag(name = "fluidCssGridGroup-bean", parent = "Uif-FluidCssGridGroup"),
78 @BeanTag(name = "fluidCssGridSection-bean", parent = "Uif-FluidCssGridSection"),
79 @BeanTag(name = "fluidCssGridSubSection-bean", parent = "Uif-FluidCssGridSubSection"),
80 @BeanTag(name = "listGroup-bean", parent = "Uif-ListGroup"),
81 @BeanTag(name = "listSection-bean", parent = "Uif-ListSection"),
82 @BeanTag(name = "listSubSection-bean", parent = "Uif-ListSubSection"),
83 @BeanTag(name = "disclosure-listSection-bean", parent = "Uif-Disclosure-ListSection"),
84 @BeanTag(name = "disclosure-listSubSection-bean", parent = "Uif-Disclosure-ListSubSection"),
85 @BeanTag(name = "collectionGridItem-bean", parent = "Uif-CollectionGridItem"),
86 @BeanTag(name = "collectionVerticalBoxItem-bean", parent = "Uif-CollectionVerticalBoxItem"),
87 @BeanTag(name = "collectionHorizontalBoxItem-bean", parent = "Uif-CollectionHorizontalBoxItem"),
88 @BeanTag(name = "headerUpperGroup-bean", parent = "Uif-HeaderUpperGroup"),
89 @BeanTag(name = "headerRightGroup-bean", parent = "Uif-HeaderRightGroup"),
90 @BeanTag(name = "headerLowerGroup-bean", parent = "Uif-HeaderLowerGroup"),
91 @BeanTag(name = "footer-bean", parent = "Uif-FooterBase"),
92 @BeanTag(name = "formFooter-bean", parent = "Uif-FormFooter"),
93 @BeanTag(name = "actionsGroup-bean", parent = "Uif-ActionsGroup"),
94 @BeanTag(name = "disclosureActionsGroup-bean", parent = "Uif-DisclosureActionsGroup"),
95 @BeanTag(name = "disclosureActions-reqMessageGroup-bean", parent = "Uif-DisclosureActions-ReqMessageGroup"),
96 @BeanTag(name = "inactiveItemsActionsGroup-bean", parent = "Uif-InactiveItemsActionsGroup"),
97 @BeanTag(name = "documentInfoGroup-bean", parent = "Uif-DocumentInfoGroup"),
98 @BeanTag(name = "documentOverviewSection-bean", parent = "Uif-DocumentOverviewSection"),
99 @BeanTag(name = "documentAdHocRecipientsSection-bean", parent = "Uif-DocumentAdHocRecipientsSection"),
100 @BeanTag(name = "documentRouteLogSection-bean", parent = "Uif-DocumentRouteLogSection"),
101 @BeanTag(name = "documentPageFooter-bean", parent = "Uif-DocumentPageFooter"),
102 @BeanTag(name = "incidentDetailGroup-bean", parent = "Uif-IncidentDetailGroup"),
103 @BeanTag(name = "incidentStackTraceGroup-bean", parent = "Uif-IncidentStackTraceGroup"),
104 @BeanTag(name = "incidentReportFooter-bean", parent = "Uif-IncidentReportFooter"),
105 @BeanTag(name = "initiatedDocumentFooter-bean", parent = "InitiatedDocumentFooter"),
106 @BeanTag(name = "inquiryFooter-bean", parent = "Uif-InquiryFooter"),
107 @BeanTag(name = "lookupCriteriaGroup-bean", parent = "Uif-LookupCriteriaGroup"),
108 @BeanTag(name = "lookupPageHeaderGroup-bean", parent = "Uif-LookupPageHeaderGroup"),
109 @BeanTag(name = "lookupCriteriaFooter-bean", parent = "Uif-LookupCriteriaFooter"),
110 @BeanTag(name = "lookupResultsFooter-bean", parent = "Uif-LookupResultsFooter"),
111 @BeanTag(name = "maintenanceGridGroup-bean", parent = "Uif-MaintenanceGridGroup"),
112 @BeanTag(name = "maintenanceHorizontalBoxGroup-bean", parent = "Uif-MaintenanceHorizontalBoxGroup"),
113 @BeanTag(name = "maintenanceVerticalBoxGroup-bean", parent = "Uif-MaintenanceVerticalBoxGroup"),
114 @BeanTag(name = "maintenanceGridSection-bean", parent = "Uif-MaintenanceGridSection"),
115 @BeanTag(name = "maintenanceGridSubSection-bean", parent = "Uif-MaintenanceGridSubSection"),
116 @BeanTag(name = "maintenanceHorizontalBoxSection-bean", parent = "Uif-MaintenanceHorizontalBoxSection"),
117 @BeanTag(name = "maintenanceVerticalBoxSection-bean", parent = "Uif-MaintenanceVerticalBoxSection"),
118 @BeanTag(name = "maintenanceHorizontalBoxSubSection-bean", parent = "Uif-MaintenanceHorizontalBoxSubSection"),
119 @BeanTag(name = "maintenanceVerticalBoxSubSection-bean", parent = "Uif-MaintenanceVerticalBoxSubSection")
120 })
121 public class Group extends ContainerBase {
122 private static final long serialVersionUID = 7953641325356535509L;
123
124 private String fieldBindByNamePrefix;
125 private String fieldBindingObjectPath;
126
127 private Disclosure disclosure;
128 private Scrollpane scrollpane;
129
130 private List<? extends Component> items;
131
132
133
134
135 public Group() {
136 items = new ArrayList<Component>();
137 }
138
139
140
141
142
143
144
145
146
147
148
149
150 @Override
151 public void performInitialization(View view, Object model) {
152 super.performInitialization(view, model);
153
154 for (Component component : getItems()) {
155
156
157 if (component instanceof DataBinding) {
158 DataBinding dataBinding = (DataBinding) component;
159
160 if (StringUtils.isNotBlank(getFieldBindByNamePrefix())) {
161 String bindByNamePrefixToSet = getFieldBindByNamePrefix();
162
163 if (StringUtils.isNotBlank(dataBinding.getBindingInfo().getBindByNamePrefix())) {
164 bindByNamePrefixToSet += "." + dataBinding.getBindingInfo().getBindByNamePrefix();
165 }
166 dataBinding.getBindingInfo().setBindByNamePrefix(bindByNamePrefixToSet);
167 }
168
169 if (StringUtils.isNotBlank(fieldBindingObjectPath) && StringUtils.isBlank(
170 dataBinding.getBindingInfo().getBindingObjectPath())) {
171 dataBinding.getBindingInfo().setBindingObjectPath(fieldBindingObjectPath);
172 }
173 }
174
175 else if (component instanceof FieldGroup) {
176 FieldGroup fieldGroup = (FieldGroup) component;
177
178 if (fieldGroup.getGroup() != null) {
179 if (StringUtils.isBlank(fieldGroup.getGroup().getFieldBindByNamePrefix())) {
180 fieldGroup.getGroup().setFieldBindByNamePrefix(fieldBindByNamePrefix);
181 }
182 if (StringUtils.isBlank(fieldGroup.getGroup().getFieldBindingObjectPath())) {
183 fieldGroup.getGroup().setFieldBindingObjectPath(fieldBindingObjectPath);
184 }
185 }
186 } else if (component instanceof Group) {
187 Group subGroup = (Group) component;
188 if (StringUtils.isNotBlank(getFieldBindByNamePrefix())) {
189 if (StringUtils.isNotBlank(subGroup.getFieldBindByNamePrefix())) {
190 subGroup.setFieldBindByNamePrefix(
191 getFieldBindByNamePrefix() + "." + subGroup.getFieldBindByNamePrefix());
192 } else {
193 subGroup.setFieldBindByNamePrefix(getFieldBindByNamePrefix());
194 }
195 }
196 if (StringUtils.isNotBlank(getFieldBindingObjectPath())) {
197 if (StringUtils.isNotBlank(subGroup.getFieldBindingObjectPath())) {
198 subGroup.setFieldBindingObjectPath(
199 getFieldBindingObjectPath() + "." + subGroup.getFieldBindingObjectPath());
200 } else {
201 subGroup.setFieldBindingObjectPath(getFieldBindingObjectPath());
202 }
203 }
204 }
205 }
206 }
207
208
209
210
211 @Override
212 public List<Component> getComponentsForLifecycle() {
213 List<Component> components = super.getComponentsForLifecycle();
214
215 components.add(disclosure);
216 components.add(scrollpane);
217
218 return components;
219 }
220
221
222
223
224 @Override
225 public Set<Class<? extends Component>> getSupportedComponents() {
226 Set<Class<? extends Component>> supportedComponents = new HashSet<Class<? extends Component>>();
227 supportedComponents.add(Field.class);
228 supportedComponents.add(Group.class);
229
230 return supportedComponents;
231 }
232
233
234
235
236 @Override
237 public String getComponentTypeName() {
238 return "group";
239 }
240
241
242
243
244
245
246
247
248
249
250
251
252
253 @BeanTagAttribute(name = "fieldBindByNamePrefix")
254 public String getFieldBindByNamePrefix() {
255 return this.fieldBindByNamePrefix;
256 }
257
258
259
260
261
262
263 public void setFieldBindByNamePrefix(String fieldBindByNamePrefix) {
264 this.fieldBindByNamePrefix = fieldBindByNamePrefix;
265 }
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282 @BeanTagAttribute(name = "fieldBindingObjectPath")
283 public String getFieldBindingObjectPath() {
284 return this.fieldBindingObjectPath;
285 }
286
287
288
289
290
291
292 public void setFieldBindingObjectPath(String fieldBindingObjectPath) {
293 this.fieldBindingObjectPath = fieldBindingObjectPath;
294 }
295
296
297
298
299
300
301
302 @BeanTagAttribute(name = "Disclosure", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
303 public Disclosure getDisclosure() {
304 return this.disclosure;
305 }
306
307
308
309
310
311
312 public void setDisclosure(Disclosure disclosure) {
313 this.disclosure = disclosure;
314 }
315
316
317
318
319
320
321
322 @BeanTagAttribute(name = "scrollpane", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
323 public Scrollpane getScrollpane() {
324 return this.scrollpane;
325 }
326
327
328
329
330
331
332 public void setScrollpane(Scrollpane scrollpane) {
333 this.scrollpane = scrollpane;
334 }
335
336
337
338
339 @Override
340 @BeanTagAttribute(name = "items", type = BeanTagAttribute.AttributeType.LISTBEAN)
341 public List<? extends Component> getItems() {
342 return this.items;
343 }
344
345
346
347
348
349
350 @Override
351 public void setItems(List<? extends Component> items) {
352 this.items = items;
353 }
354
355
356
357
358 @Override
359 protected <T> void copyProperties(T component) {
360 super.copyProperties(component);
361 Group groupCopy = (Group) component;
362 groupCopy.setFieldBindByNamePrefix(this.fieldBindByNamePrefix);
363 groupCopy.setFieldBindingObjectPath(this.fieldBindingObjectPath);
364
365 if (this.disclosure != null) {
366 groupCopy.setDisclosure((Disclosure) this.disclosure.copy());
367 }
368
369 if (this.scrollpane != null) {
370 groupCopy.setScrollpane((Scrollpane) this.scrollpane.copy());
371 }
372 }
373
374
375
376
377 @Override
378 public void completeValidation(ValidationTrace tracer) {
379 tracer.addBean(this);
380
381
382 for (int i = 0; i < getItems().size(); i++) {
383 if (getItems().get(i).getClass() == PageGroup.class || getItems().get(i).getClass()
384 == NavigationGroup.class) {
385 String currentValues[] = {"item(" + i + ").class =" + getItems().get(i).getClass()};
386 tracer.createError("Items in Group cannot be PageGroup or NaviagtionGroup", currentValues);
387 }
388 }
389
390
391 if (getLayoutManager() == null) {
392 if (Validator.checkExpressions(this, "layoutManager")) {
393 String currentValues[] = {"layoutManager = " + getLayoutManager()};
394 tracer.createError("LayoutManager must be set", currentValues);
395 }
396 }
397
398 super.completeValidation(tracer.getCopy());
399 }
400
401 }