1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.uif.control;
17
18 import org.kuali.rice.krad.datadictionary.parse.BeanTag;
19 import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
20 import org.kuali.rice.krad.datadictionary.validator.ErrorReport;
21 import org.kuali.rice.krad.datadictionary.validator.ValidationTrace;
22 import org.kuali.rice.krad.uif.component.Component;
23 import org.kuali.rice.krad.uif.element.Message;
24 import org.kuali.rice.krad.uif.util.ComponentFactory;
25 import org.kuali.rice.krad.uif.view.View;
26
27 import java.util.ArrayList;
28 import java.util.List;
29
30
31
32
33
34
35
36 @BeanTag(name = "checkboxControl-bean", parent = "Uif-CheckboxControl")
37 public class CheckboxControl extends ControlBase implements ValueConfiguredControl {
38 private static final long serialVersionUID = -1397028958569144230L;
39
40 private String value;
41 private String checkboxLabel;
42
43 private Message richLabelMessage;
44 private List<Component> inlineComponents;
45
46 public CheckboxControl() {
47 super();
48 }
49
50
51
52
53
54
55 @Override
56 public void performApplyModel(View view, Object model, Component parent) {
57 super.performApplyModel(view, model, parent);
58
59 if (richLabelMessage == null) {
60 Message message = ComponentFactory.getMessage();
61 view.assignComponentIds(message);
62 message.setMessageText(checkboxLabel);
63 message.setInlineComponents(inlineComponents);
64 message.setGenerateSpan(false);
65 view.getViewHelperService().performComponentInitialization(view, model, message);
66 this.setRichLabelMessage(message);
67 }
68 }
69
70
71
72
73 @Override
74 public List<Component> getComponentsForLifecycle() {
75 List<Component> components = super.getComponentsForLifecycle();
76
77 components.add(richLabelMessage);
78
79 return components;
80 }
81
82
83
84
85
86
87
88
89
90
91
92
93 @BeanTagAttribute(name="value")
94 public String getValue() {
95 return value;
96 }
97
98
99
100
101
102
103 public void setValue(String value) {
104 this.value = value;
105 }
106
107
108
109
110
111
112 @BeanTagAttribute(name="checkboxLabel")
113 public String getCheckboxLabel() {
114 return checkboxLabel;
115 }
116
117
118
119
120
121
122 public void setCheckboxLabel(String checkboxLabel) {
123 this.checkboxLabel = checkboxLabel;
124 }
125
126
127
128
129
130
131
132
133 @BeanTagAttribute(name="richLabelMessage",type= BeanTagAttribute.AttributeType.SINGLEBEAN)
134 public Message getRichLabelMessage() {
135 return richLabelMessage;
136 }
137
138
139
140
141
142
143
144
145 public void setRichLabelMessage(Message richLabelMessage) {
146 this.richLabelMessage = richLabelMessage;
147 }
148
149
150
151
152
153
154 @BeanTagAttribute(name="inlineComponents",type= BeanTagAttribute.AttributeType.LISTBEAN)
155 public List<Component> getInlineComponents() {
156 return inlineComponents;
157 }
158
159
160
161
162
163
164 public void setInlineComponents(List<Component> inlineComponents) {
165 this.inlineComponents = inlineComponents;
166 }
167
168
169
170
171 @Override
172 protected <T> void copyProperties(T component) {
173 super.copyProperties(component);
174 CheckboxControl checkboxControlCopy = (CheckboxControl) component;
175 checkboxControlCopy.setValue(this.value);
176 checkboxControlCopy.setCheckboxLabel(this.checkboxLabel);
177
178 if (this.richLabelMessage != null) {
179 checkboxControlCopy.setRichLabelMessage((Message)this.richLabelMessage.copy());
180 }
181
182 if(inlineComponents != null) {
183 List<Component> inlineComponentsCopy = new ArrayList<Component>();
184 for(Component inlineComponent : inlineComponents) {
185 inlineComponentsCopy.add((Component)inlineComponent.copy());
186 }
187 checkboxControlCopy.setInlineComponents(inlineComponentsCopy);
188 }
189 }
190
191
192
193
194 @Override
195 public void completeValidation(ValidationTrace tracer){
196 tracer.addBean(this);
197
198 super.completeValidation(tracer.getCopy());
199 }
200 }