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.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.component.Component;
23 import org.kuali.rice.krad.uif.field.InputField;
24 import org.kuali.rice.krad.uif.view.View;
25 import org.kuali.rice.krad.uif.widget.DatePicker;
26
27 import java.util.List;
28
29
30
31
32
33
34
35 @BeanTags({@BeanTag(name = "textControl-bean", parent = "Uif-TextControl"),
36 @BeanTag(name = "smallTextControl-bean", parent = "Uif-SmallTextControl"),
37 @BeanTag(name = "mediumTextControl-bean", parent = "Uif-MediumTextControl"),
38 @BeanTag(name = "largeTextControl-bean", parent = "Uif-LargeTextControl"),
39 @BeanTag(name = "currencyTextControl-bean", parent = "Uif-CurrencyTextControl"),
40 @BeanTag(name = "dateControl-bean", parent = "Uif-DateControl")})
41 public class TextControl extends ControlBase implements SizedControl {
42 private static final long serialVersionUID = -8267606288443759880L;
43
44 private int size;
45 private Integer maxLength;
46 private Integer minLength;
47
48 private DatePicker datePicker;
49 private String watermarkText = StringUtils.EMPTY;
50 private boolean textExpand;
51
52 public TextControl() {
53 super();
54 }
55
56
57
58
59 @Override
60 public List<Component> getComponentsForLifecycle() {
61 List<Component> components = super.getComponentsForLifecycle();
62
63 components.add(datePicker);
64
65 return components;
66 }
67
68
69
70
71
72
73
74
75
76
77
78 @Override
79 public void performFinalize(View view, Object model, Component parent) {
80 super.performFinalize(view, model, parent);
81
82 if (parent instanceof InputField) {
83 InputField field = (InputField) parent;
84 if (getMaxLength() == null) {
85 setMaxLength(field.getMaxLength());
86 }
87
88 if (getMinLength() == null) {
89 setMinLength(field.getMinLength());
90 }
91 }
92 }
93
94
95
96
97 @BeanTagAttribute(name = "size")
98 public int getSize() {
99 return this.size;
100 }
101
102
103
104
105 public void setSize(int size) {
106 this.size = size;
107 }
108
109
110
111
112
113
114
115
116 @BeanTagAttribute(name = "maxLength")
117 public Integer getMaxLength() {
118 return maxLength;
119 }
120
121
122
123
124
125
126 public void setMaxLength(Integer maxLength) {
127 this.maxLength = maxLength;
128 }
129
130
131
132
133
134
135
136
137 @BeanTagAttribute(name = "minLength")
138 public Integer getMinLength() {
139 return minLength;
140 }
141
142
143
144
145
146
147 public void setMinLength(Integer minLength) {
148 this.minLength = minLength;
149 }
150
151
152
153
154
155
156
157
158 @BeanTagAttribute(name = "datePicker", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
159 public DatePicker getDatePicker() {
160 return this.datePicker;
161 }
162
163
164
165
166
167
168 public void setDatePicker(DatePicker datePicker) {
169 this.datePicker = datePicker;
170 }
171
172
173
174
175
176
177
178
179
180
181
182
183 @BeanTagAttribute(name = "watermarkText")
184 public String getWatermarkText() {
185 return this.watermarkText;
186 }
187
188
189
190
191
192
193 public void setWatermarkText(String watermarkText) {
194
195
196 if (StringUtils.isNotEmpty(watermarkText)) {
197 watermarkText = watermarkText + " ";
198 }
199 this.watermarkText = watermarkText;
200 }
201
202
203
204
205
206
207
208 @BeanTagAttribute(name = "textExpand")
209 public boolean isTextExpand() {
210 return this.textExpand;
211 }
212
213
214
215
216
217
218 public void setTextExpand(boolean textExpand) {
219 this.textExpand = textExpand;
220 }
221
222
223
224
225 @Override
226 protected <T> void copyProperties(T component) {
227 super.copyProperties(component);
228 TextControl textControlCopy = (TextControl) component;
229 textControlCopy.setSize(this.size);
230 textControlCopy.setMaxLength(this.maxLength);
231 textControlCopy.setMinLength(this.minLength);
232
233 if(datePicker != null) {
234 textControlCopy.setDatePicker((DatePicker)this.datePicker.copy());
235 }
236
237 textControlCopy.setWatermarkText(this.watermarkText);
238 textControlCopy.setTextExpand(this.textExpand);
239 }
240 }