1 package org.rcfaces.core.internal.taglib;
2
3 import javax.faces.application.Application;
4 import javax.faces.component.UIComponent;
5 import org.rcfaces.core.internal.component.Properties;
6 import org.rcfaces.core.component.NumberEntryComponent;
7 import javax.el.ValueExpression;
8 import javax.faces.component.UIViewRoot;
9 import org.apache.commons.logging.Log;
10 import javax.servlet.jsp.tagext.Tag;
11 import org.apache.commons.logging.LogFactory;
12 import org.rcfaces.core.internal.tools.ListenersTools1_2;
13 import org.rcfaces.core.internal.tools.ListenersTools;
14 import javax.faces.context.FacesContext;
15
16 public class NumberEntryTag extends AbstractInputTag implements Tag {
17
18
19 private static final Log LOG=LogFactory.getLog(NumberEntryTag.class);
20
21 private ValueExpression required;
22 private ValueExpression autoTab;
23 private ValueExpression valueChangeListeners;
24 private ValueExpression focusStyleClass;
25 private ValueExpression selectionListeners;
26 private ValueExpression readOnly;
27 private ValueExpression numberFormatType;
28 private ValueExpression literalLocale;
29 private ValueExpression componentLocale;
30 private ValueExpression errorStyleClass;
31 private ValueExpression fatalStyleClass;
32 private ValueExpression infoStyleClass;
33 private ValueExpression warnStyleClass;
34 private ValueExpression alternateText;
35 private ValueExpression autoCompletion;
36 private ValueExpression integerDigits;
37 private ValueExpression fractionDigits;
38 private ValueExpression numberFormat;
39 private ValueExpression integerStep;
40 private ValueExpression fractionStep;
41 private ValueExpression number;
42 private ValueExpression minimum;
43 private ValueExpression defaultNumber;
44 private ValueExpression maximum;
45 public String getComponentType() {
46 return NumberEntryComponent.COMPONENT_TYPE;
47 }
48
49 public final void setRequired(ValueExpression required) {
50 this.required = required;
51 }
52
53 public final void setAutoTab(ValueExpression autoTab) {
54 this.autoTab = autoTab;
55 }
56
57 public final void setValueChangeListener(ValueExpression valueChangeListeners) {
58 this.valueChangeListeners = valueChangeListeners;
59 }
60
61 public final void setFocusStyleClass(ValueExpression focusStyleClass) {
62 this.focusStyleClass = focusStyleClass;
63 }
64
65 public final void setSelectionListener(ValueExpression selectionListeners) {
66 this.selectionListeners = selectionListeners;
67 }
68
69 public final void setReadOnly(ValueExpression readOnly) {
70 this.readOnly = readOnly;
71 }
72
73 public final void setNumberFormatType(ValueExpression numberFormatType) {
74 this.numberFormatType = numberFormatType;
75 }
76
77 public final void setLiteralLocale(ValueExpression literalLocale) {
78 this.literalLocale = literalLocale;
79 }
80
81 public final void setComponentLocale(ValueExpression componentLocale) {
82 this.componentLocale = componentLocale;
83 }
84
85 public final void setErrorStyleClass(ValueExpression errorStyleClass) {
86 this.errorStyleClass = errorStyleClass;
87 }
88
89 public final void setFatalStyleClass(ValueExpression fatalStyleClass) {
90 this.fatalStyleClass = fatalStyleClass;
91 }
92
93 public final void setInfoStyleClass(ValueExpression infoStyleClass) {
94 this.infoStyleClass = infoStyleClass;
95 }
96
97 public final void setWarnStyleClass(ValueExpression warnStyleClass) {
98 this.warnStyleClass = warnStyleClass;
99 }
100
101 public final void setAlternateText(ValueExpression alternateText) {
102 this.alternateText = alternateText;
103 }
104
105 public final void setAutoCompletion(ValueExpression autoCompletion) {
106 this.autoCompletion = autoCompletion;
107 }
108
109 public final void setIntegerDigits(ValueExpression integerDigits) {
110 this.integerDigits = integerDigits;
111 }
112
113 public final void setFractionDigits(ValueExpression fractionDigits) {
114 this.fractionDigits = fractionDigits;
115 }
116
117 public final void setNumberFormat(ValueExpression numberFormat) {
118 this.numberFormat = numberFormat;
119 }
120
121 public final void setIntegerStep(ValueExpression integerStep) {
122 this.integerStep = integerStep;
123 }
124
125 public final void setFractionStep(ValueExpression fractionStep) {
126 this.fractionStep = fractionStep;
127 }
128
129 public final void setNumber(ValueExpression number) {
130 this.number = number;
131 }
132
133 public final void setMinimum(ValueExpression minimum) {
134 this.minimum = minimum;
135 }
136
137 public final void setDefaultNumber(ValueExpression defaultNumber) {
138 this.defaultNumber = defaultNumber;
139 }
140
141 public final void setMaximum(ValueExpression maximum) {
142 this.maximum = maximum;
143 }
144
145 protected void setProperties(UIComponent uiComponent) {
146 if (LOG.isDebugEnabled()) {
147 if (NumberEntryComponent.COMPONENT_TYPE==getComponentType()) {
148 LOG.debug("Component id='"+getId()+"' type='"+getComponentType()+"'.");
149 }
150 LOG.debug(" required='"+required+"'");
151 LOG.debug(" autoTab='"+autoTab+"'");
152 LOG.debug(" focusStyleClass='"+focusStyleClass+"'");
153 LOG.debug(" readOnly='"+readOnly+"'");
154 LOG.debug(" numberFormatType='"+numberFormatType+"'");
155 LOG.debug(" literalLocale='"+literalLocale+"'");
156 LOG.debug(" componentLocale='"+componentLocale+"'");
157 LOG.debug(" errorStyleClass='"+errorStyleClass+"'");
158 LOG.debug(" fatalStyleClass='"+fatalStyleClass+"'");
159 LOG.debug(" infoStyleClass='"+infoStyleClass+"'");
160 LOG.debug(" warnStyleClass='"+warnStyleClass+"'");
161 LOG.debug(" alternateText='"+alternateText+"'");
162 LOG.debug(" autoCompletion='"+autoCompletion+"'");
163 LOG.debug(" integerDigits='"+integerDigits+"'");
164 LOG.debug(" fractionDigits='"+fractionDigits+"'");
165 LOG.debug(" numberFormat='"+numberFormat+"'");
166 LOG.debug(" integerStep='"+integerStep+"'");
167 LOG.debug(" fractionStep='"+fractionStep+"'");
168 LOG.debug(" number='"+number+"'");
169 LOG.debug(" minimum='"+minimum+"'");
170 LOG.debug(" defaultNumber='"+defaultNumber+"'");
171 LOG.debug(" maximum='"+maximum+"'");
172 }
173 if ((uiComponent instanceof NumberEntryComponent)==false) {
174 if (uiComponent instanceof UIViewRoot) {
175 throw new IllegalStateException("The first component of the page must be a UIViewRoot component !");
176 }
177 throw new IllegalStateException("Component specified by tag is not instanceof of 'NumberEntryComponent'.");
178 }
179
180 super.setProperties(uiComponent);
181
182 NumberEntryComponent component = (NumberEntryComponent) uiComponent;
183 FacesContext facesContext = getFacesContext();
184
185 if (required != null) {
186 if (required.isLiteralText()==false) {
187 component.setValueExpression(Properties.REQUIRED, required);
188
189 } else {
190 component.setRequired(getBool(required.getExpressionString()));
191 }
192 }
193
194 if (autoTab != null) {
195 if (autoTab.isLiteralText()==false) {
196 component.setValueExpression(Properties.AUTO_TAB, autoTab);
197
198 } else {
199 component.setAutoTab(getBool(autoTab.getExpressionString()));
200 }
201 }
202
203 if (valueChangeListeners != null) {
204 ListenersTools1_2.parseListener(facesContext, component, ListenersTools.VALUE_CHANGE_LISTENER_TYPE, valueChangeListeners);
205 }
206
207 if (focusStyleClass != null) {
208 if (focusStyleClass.isLiteralText()==false) {
209 component.setValueExpression(Properties.FOCUS_STYLE_CLASS, focusStyleClass);
210
211 } else {
212 component.setFocusStyleClass(focusStyleClass.getExpressionString());
213 }
214 }
215
216 if (selectionListeners != null) {
217 ListenersTools1_2.parseListener(facesContext, component, ListenersTools.SELECTION_LISTENER_TYPE, selectionListeners);
218 }
219
220 if (readOnly != null) {
221 if (readOnly.isLiteralText()==false) {
222 component.setValueExpression(Properties.READ_ONLY, readOnly);
223
224 } else {
225 component.setReadOnly(getBool(readOnly.getExpressionString()));
226 }
227 }
228
229 if (numberFormatType != null) {
230 if (numberFormatType.isLiteralText()==false) {
231 component.setValueExpression(Properties.NUMBER_FORMAT_TYPE, numberFormatType);
232
233 } else {
234 component.setNumberFormatType(numberFormatType.getExpressionString());
235 }
236 }
237
238 if (literalLocale != null) {
239 if (literalLocale.isLiteralText()==false) {
240 component.setValueExpression(Properties.LITERAL_LOCALE, literalLocale);
241
242 } else {
243 component.setLiteralLocale(literalLocale.getExpressionString());
244 }
245 }
246
247 if (componentLocale != null) {
248 if (componentLocale.isLiteralText()==false) {
249 component.setValueExpression(Properties.COMPONENT_LOCALE, componentLocale);
250
251 } else {
252 component.setComponentLocale(componentLocale.getExpressionString());
253 }
254 }
255
256 if (errorStyleClass != null) {
257 if (errorStyleClass.isLiteralText()==false) {
258 component.setValueExpression(Properties.ERROR_STYLE_CLASS, errorStyleClass);
259
260 } else {
261 component.setErrorStyleClass(errorStyleClass.getExpressionString());
262 }
263 }
264
265 if (fatalStyleClass != null) {
266 if (fatalStyleClass.isLiteralText()==false) {
267 component.setValueExpression(Properties.FATAL_STYLE_CLASS, fatalStyleClass);
268
269 } else {
270 component.setFatalStyleClass(fatalStyleClass.getExpressionString());
271 }
272 }
273
274 if (infoStyleClass != null) {
275 if (infoStyleClass.isLiteralText()==false) {
276 component.setValueExpression(Properties.INFO_STYLE_CLASS, infoStyleClass);
277
278 } else {
279 component.setInfoStyleClass(infoStyleClass.getExpressionString());
280 }
281 }
282
283 if (warnStyleClass != null) {
284 if (warnStyleClass.isLiteralText()==false) {
285 component.setValueExpression(Properties.WARN_STYLE_CLASS, warnStyleClass);
286
287 } else {
288 component.setWarnStyleClass(warnStyleClass.getExpressionString());
289 }
290 }
291
292 if (alternateText != null) {
293 if (alternateText.isLiteralText()==false) {
294 component.setValueExpression(Properties.ALTERNATE_TEXT, alternateText);
295
296 } else {
297 component.setAlternateText(alternateText.getExpressionString());
298 }
299 }
300
301 if (autoCompletion != null) {
302 if (autoCompletion.isLiteralText()==false) {
303 component.setValueExpression(Properties.AUTO_COMPLETION, autoCompletion);
304
305 } else {
306 component.setAutoCompletion(getBool(autoCompletion.getExpressionString()));
307 }
308 }
309
310 if (integerDigits != null) {
311 if (integerDigits.isLiteralText()==false) {
312 component.setValueExpression(Properties.INTEGER_DIGITS, integerDigits);
313
314 } else {
315 component.setIntegerDigits(getInt(integerDigits.getExpressionString()));
316 }
317 }
318
319 if (fractionDigits != null) {
320 if (fractionDigits.isLiteralText()==false) {
321 component.setValueExpression(Properties.FRACTION_DIGITS, fractionDigits);
322
323 } else {
324 component.setFractionDigits(getInt(fractionDigits.getExpressionString()));
325 }
326 }
327
328 if (numberFormat != null) {
329 if (numberFormat.isLiteralText()==false) {
330 component.setValueExpression(Properties.NUMBER_FORMAT, numberFormat);
331
332 } else {
333 component.setNumberFormat(numberFormat.getExpressionString());
334 }
335 }
336
337 if (integerStep != null) {
338 if (integerStep.isLiteralText()==false) {
339 component.setValueExpression(Properties.INTEGER_STEP, integerStep);
340
341 } else {
342 component.setIntegerStep(integerStep.getExpressionString());
343 }
344 }
345
346 if (fractionStep != null) {
347 if (fractionStep.isLiteralText()==false) {
348 component.setValueExpression(Properties.FRACTION_STEP, fractionStep);
349
350 } else {
351 component.setFractionStep(fractionStep.getExpressionString());
352 }
353 }
354
355 if (number != null) {
356 if (number.isLiteralText()==false) {
357 component.setValueExpression(Properties.VALUE, number);
358
359 } else {
360 component.setNumber(number.getExpressionString());
361 }
362 }
363
364 if (minimum != null) {
365 if (minimum.isLiteralText()==false) {
366 component.setValueExpression(Properties.MINIMUM, minimum);
367
368 } else {
369 component.setMinimum(minimum.getExpressionString());
370 }
371 }
372
373 if (defaultNumber != null) {
374 if (defaultNumber.isLiteralText()==false) {
375 component.setValueExpression(Properties.DEFAULT_NUMBER, defaultNumber);
376
377 } else {
378 component.setDefaultNumber(defaultNumber.getExpressionString());
379 }
380 }
381
382 if (maximum != null) {
383 if (maximum.isLiteralText()==false) {
384 component.setValueExpression(Properties.MAXIMUM, maximum);
385
386 } else {
387 component.setMaximum(maximum.getExpressionString());
388 }
389 }
390 }
391
392 public void release() {
393 required = null;
394 autoTab = null;
395 valueChangeListeners = null;
396 focusStyleClass = null;
397 selectionListeners = null;
398 readOnly = null;
399 numberFormatType = null;
400 literalLocale = null;
401 componentLocale = null;
402 errorStyleClass = null;
403 fatalStyleClass = null;
404 infoStyleClass = null;
405 warnStyleClass = null;
406 alternateText = null;
407 autoCompletion = null;
408 integerDigits = null;
409 fractionDigits = null;
410 numberFormat = null;
411 integerStep = null;
412 fractionStep = null;
413 number = null;
414 minimum = null;
415 defaultNumber = null;
416 maximum = null;
417
418 super.release();
419 }
420
421 }