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.AbstractCalendarComponent;
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 abstract class AbstractCalendarTag extends AbstractInputTag implements Tag {
17
18
19 private static final Log LOG=LogFactory.getLog(AbstractCalendarTag.class);
20
21 private ValueExpression selectionListeners;
22 private ValueExpression readOnly;
23 private ValueExpression literalLocale;
24 private ValueExpression literalTimeZone;
25 private ValueExpression componentLocale;
26 private ValueExpression componentTimeZone;
27 private ValueExpression clientDatesStrategy;
28 private ValueExpression twoDigitYearStart;
29 private ValueExpression minDate;
30 private ValueExpression maxDate;
31 private ValueExpression cursorDate;
32 private ValueExpression disabledWeekDays;
33 public final void setSelectionListener(ValueExpression selectionListeners) {
34 this.selectionListeners = selectionListeners;
35 }
36
37 public final void setReadOnly(ValueExpression readOnly) {
38 this.readOnly = readOnly;
39 }
40
41 public final void setLiteralLocale(ValueExpression literalLocale) {
42 this.literalLocale = literalLocale;
43 }
44
45 public final void setLiteralTimeZone(ValueExpression literalTimeZone) {
46 this.literalTimeZone = literalTimeZone;
47 }
48
49 public final void setComponentLocale(ValueExpression componentLocale) {
50 this.componentLocale = componentLocale;
51 }
52
53 public final void setComponentTimeZone(ValueExpression componentTimeZone) {
54 this.componentTimeZone = componentTimeZone;
55 }
56
57 public final void setClientDatesStrategy(ValueExpression clientDatesStrategy) {
58 this.clientDatesStrategy = clientDatesStrategy;
59 }
60
61 public final void setTwoDigitYearStart(ValueExpression twoDigitYearStart) {
62 this.twoDigitYearStart = twoDigitYearStart;
63 }
64
65 public final void setMinDate(ValueExpression minDate) {
66 this.minDate = minDate;
67 }
68
69 public final void setMaxDate(ValueExpression maxDate) {
70 this.maxDate = maxDate;
71 }
72
73 public final void setCursorDate(ValueExpression cursorDate) {
74 this.cursorDate = cursorDate;
75 }
76
77 public final void setDisabledWeekDays(ValueExpression disabledWeekDays) {
78 this.disabledWeekDays = disabledWeekDays;
79 }
80
81 protected void setProperties(UIComponent uiComponent) {
82 if (LOG.isDebugEnabled()) {
83 LOG.debug(" readOnly='"+readOnly+"'");
84 LOG.debug(" literalLocale='"+literalLocale+"'");
85 LOG.debug(" literalTimeZone='"+literalTimeZone+"'");
86 LOG.debug(" componentLocale='"+componentLocale+"'");
87 LOG.debug(" componentTimeZone='"+componentTimeZone+"'");
88 LOG.debug(" clientDatesStrategy='"+clientDatesStrategy+"'");
89 LOG.debug(" twoDigitYearStart='"+twoDigitYearStart+"'");
90 LOG.debug(" minDate='"+minDate+"'");
91 LOG.debug(" maxDate='"+maxDate+"'");
92 LOG.debug(" cursorDate='"+cursorDate+"'");
93 LOG.debug(" disabledWeekDays='"+disabledWeekDays+"'");
94 }
95 if ((uiComponent instanceof AbstractCalendarComponent)==false) {
96 if (uiComponent instanceof UIViewRoot) {
97 throw new IllegalStateException("The first component of the page must be a UIViewRoot component !");
98 }
99 throw new IllegalStateException("Component specified by tag is not instanceof of 'AbstractCalendarComponent'.");
100 }
101
102 super.setProperties(uiComponent);
103
104 AbstractCalendarComponent component = (AbstractCalendarComponent) uiComponent;
105 FacesContext facesContext = getFacesContext();
106
107 if (selectionListeners != null) {
108 ListenersTools1_2.parseListener(facesContext, component, ListenersTools.SELECTION_LISTENER_TYPE, selectionListeners);
109 }
110
111 if (readOnly != null) {
112 if (readOnly.isLiteralText()==false) {
113 component.setValueExpression(Properties.READ_ONLY, readOnly);
114
115 } else {
116 component.setReadOnly(getBool(readOnly.getExpressionString()));
117 }
118 }
119
120 if (literalLocale != null) {
121 if (literalLocale.isLiteralText()==false) {
122 component.setValueExpression(Properties.LITERAL_LOCALE, literalLocale);
123
124 } else {
125 component.setLiteralLocale(literalLocale.getExpressionString());
126 }
127 }
128
129 if (literalTimeZone != null) {
130 if (literalTimeZone.isLiteralText()==false) {
131 component.setValueExpression(Properties.LITERAL_TIME_ZONE, literalTimeZone);
132
133 } else {
134 component.setLiteralTimeZone(literalTimeZone.getExpressionString());
135 }
136 }
137
138 if (componentLocale != null) {
139 if (componentLocale.isLiteralText()==false) {
140 component.setValueExpression(Properties.COMPONENT_LOCALE, componentLocale);
141
142 } else {
143 component.setComponentLocale(componentLocale.getExpressionString());
144 }
145 }
146
147 if (componentTimeZone != null) {
148 if (componentTimeZone.isLiteralText()==false) {
149 component.setValueExpression(Properties.COMPONENT_TIME_ZONE, componentTimeZone);
150
151 } else {
152 component.setComponentTimeZone(componentTimeZone.getExpressionString());
153 }
154 }
155
156 if (clientDatesStrategy != null) {
157 if (clientDatesStrategy.isLiteralText()==false) {
158 component.setValueExpression(Properties.CLIENT_DATES_STRATEGY, clientDatesStrategy);
159
160 } else {
161 component.setClientDatesStrategy(clientDatesStrategy.getExpressionString());
162 }
163 }
164
165 if (twoDigitYearStart != null) {
166 if (twoDigitYearStart.isLiteralText()==false) {
167 component.setValueExpression(Properties.TWO_DIGIT_YEAR_START, twoDigitYearStart);
168
169 } else {
170 component.setTwoDigitYearStart(twoDigitYearStart.getExpressionString());
171 }
172 }
173
174 if (minDate != null) {
175 if (minDate.isLiteralText()==false) {
176 component.setValueExpression(Properties.MIN_DATE, minDate);
177
178 } else {
179 component.setMinDate(minDate.getExpressionString());
180 }
181 }
182
183 if (maxDate != null) {
184 if (maxDate.isLiteralText()==false) {
185 component.setValueExpression(Properties.MAX_DATE, maxDate);
186
187 } else {
188 component.setMaxDate(maxDate.getExpressionString());
189 }
190 }
191
192 if (cursorDate != null) {
193 if (cursorDate.isLiteralText()==false) {
194 component.setValueExpression(Properties.CURSOR_DATE, cursorDate);
195
196 } else {
197 component.setCursorDate(cursorDate.getExpressionString());
198 }
199 }
200
201 if (disabledWeekDays != null) {
202 if (disabledWeekDays.isLiteralText()==false) {
203 component.setValueExpression(Properties.DISABLED_WEEK_DAYS, disabledWeekDays);
204
205 } else {
206 component.setDisabledWeekDays(disabledWeekDays.getExpressionString());
207 }
208 }
209 }
210
211 public void release() {
212 selectionListeners = null;
213 readOnly = null;
214 literalLocale = null;
215 literalTimeZone = null;
216 componentLocale = null;
217 componentTimeZone = null;
218 clientDatesStrategy = null;
219 twoDigitYearStart = null;
220 minDate = null;
221 maxDate = null;
222 cursorDate = null;
223 disabledWeekDays = null;
224
225 super.release();
226 }
227
228 }