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.parse.BeanTags;
22 import org.kuali.rice.krad.uif.UifConstants;
23 import org.kuali.rice.krad.uif.component.Component;
24 import org.kuali.rice.krad.uif.container.Group;
25 import org.kuali.rice.krad.uif.view.View;
26
27 import java.util.List;
28
29
30
31
32
33
34
35
36
37 @BeanTags({@BeanTag(name = "fieldGroup-bean", parent = "Uif-FieldGroupBase"),
38 @BeanTag(name = "verticalFieldGroup-bean", parent = "Uif-VerticalFieldGroup"),
39 @BeanTag(name = "horizontalFieldGroup-bean", parent = "Uif-HorizontalFieldGroup")})
40 public class FieldGroup extends FieldBase {
41 private static final long serialVersionUID = -505654043702442196L;
42
43 private Group group;
44
45 public FieldGroup() {
46 super();
47 }
48
49
50
51
52
53
54
55
56
57
58
59 @Override
60 public void performInitialization(View view, Object model) {
61 super.performInitialization(view, model);
62
63 if (StringUtils.isNotBlank(getAlign()) && group != null) {
64 group.setAlign(getAlign());
65 }
66 }
67
68 @Override
69 public void performFinalize(View view, Object model, Component parent) {
70 super.performFinalize(view, model, parent);
71
72 this.addDataAttribute(UifConstants.DataAttributes.PARENT, parent.getId());
73 if (group != null) {
74 this.addDataAttribute(UifConstants.DataAttributes.GROUP, group.getId());
75 }
76
77 setNestedComponentIdAndSuffix(getFieldLabel(), UifConstants.IdSuffixes.LABEL);
78
79 if (this.getFieldLabel() != null) {
80 this.getFieldLabel().setLabelForComponentId(this.getId() + UifConstants.IdSuffixes.FIELDSET);
81 }
82 }
83
84
85
86
87 @Override
88 public List<Component> getComponentsForLifecycle() {
89 List<Component> components = super.getComponentsForLifecycle();
90
91 components.add(group);
92
93 return components;
94 }
95
96
97
98
99
100
101 @BeanTagAttribute(name = "group", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
102 public Group getGroup() {
103 return this.group;
104 }
105
106
107
108
109
110
111 public void setGroup(Group group) {
112 this.group = group;
113 }
114
115
116
117
118
119
120
121
122
123
124
125 @BeanTagAttribute(name = "items", type = BeanTagAttribute.AttributeType.LISTBEAN)
126 public List<? extends Component> getItems() {
127 if (group != null) {
128 return group.getItems();
129 }
130
131 return null;
132 }
133
134
135
136
137
138
139
140
141
142
143
144 public void setItems(List<? extends Component> items) {
145 if (group != null) {
146 group.setItems(items);
147 }
148 }
149
150
151
152
153 @Override
154 protected <T> void copyProperties(T component) {
155 super.copyProperties(component);
156 FieldGroup fieldGroupCopy = (FieldGroup) component;
157
158 if (this.group != null) {
159 fieldGroupCopy.setGroup((Group)this.group.copy());
160 }
161 }
162 }