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