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 javax.el.ValueExpression;
7 import javax.faces.component.UIViewRoot;
8 import org.apache.commons.logging.Log;
9 import org.rcfaces.core.component.SpinnerComponent;
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 SpinnerTag extends TextEntryTag implements Tag {
17
18
19 private static final Log LOG=LogFactory.getLog(SpinnerTag.class);
20
21 private ValueExpression minimum;
22 private ValueExpression maximum;
23 private ValueExpression cycleValue;
24 private ValueExpression step;
25 public String getComponentType() {
26 return SpinnerComponent.COMPONENT_TYPE;
27 }
28
29 public final void setMinimum(ValueExpression minimum) {
30 this.minimum = minimum;
31 }
32
33 public final void setMaximum(ValueExpression maximum) {
34 this.maximum = maximum;
35 }
36
37 public final void setCycleValue(ValueExpression cycleValue) {
38 this.cycleValue = cycleValue;
39 }
40
41 public final void setStep(ValueExpression step) {
42 this.step = step;
43 }
44
45 protected void setProperties(UIComponent uiComponent) {
46 if (LOG.isDebugEnabled()) {
47 if (SpinnerComponent.COMPONENT_TYPE==getComponentType()) {
48 LOG.debug("Component id='"+getId()+"' type='"+getComponentType()+"'.");
49 }
50 LOG.debug(" minimum='"+minimum+"'");
51 LOG.debug(" maximum='"+maximum+"'");
52 LOG.debug(" cycleValue='"+cycleValue+"'");
53 LOG.debug(" step='"+step+"'");
54 }
55 if ((uiComponent instanceof SpinnerComponent)==false) {
56 if (uiComponent instanceof UIViewRoot) {
57 throw new IllegalStateException("The first component of the page must be a UIViewRoot component !");
58 }
59 throw new IllegalStateException("Component specified by tag is not instanceof of 'SpinnerComponent'.");
60 }
61
62 super.setProperties(uiComponent);
63
64 SpinnerComponent component = (SpinnerComponent) uiComponent;
65 FacesContext facesContext = getFacesContext();
66
67 if (minimum != null) {
68 if (minimum.isLiteralText()==false) {
69 component.setValueExpression(Properties.MINIMUM, minimum);
70
71 } else {
72 component.setMinimum(getDouble(minimum.getExpressionString()));
73 }
74 }
75
76 if (maximum != null) {
77 if (maximum.isLiteralText()==false) {
78 component.setValueExpression(Properties.MAXIMUM, maximum);
79
80 } else {
81 component.setMaximum(getDouble(maximum.getExpressionString()));
82 }
83 }
84
85 if (cycleValue != null) {
86 if (cycleValue.isLiteralText()==false) {
87 component.setValueExpression(Properties.CYCLE_VALUE, cycleValue);
88
89 } else {
90 component.setCycleValue(getBool(cycleValue.getExpressionString()));
91 }
92 }
93
94 if (step != null) {
95 if (step.isLiteralText()==false) {
96 component.setValueExpression(Properties.STEP, step);
97
98 } else {
99 component.setStep(step.getExpressionString());
100 }
101 }
102 }
103
104 public void release() {
105 minimum = null;
106 maximum = null;
107 cycleValue = null;
108 step = null;
109
110 super.release();
111 }
112
113 }