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 javax.servlet.jsp.tagext.Tag;
10 import org.apache.commons.logging.LogFactory;
11 import org.rcfaces.core.component.SelectItemsIteratorComponent;
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 SelectItemsIteratorTag extends CameliaTag implements Tag {
17
18
19 private static final Log LOG=LogFactory.getLog(SelectItemsIteratorTag.class);
20
21 private ValueExpression items;
22 private ValueExpression var;
23 private ValueExpression itemIndexVar;
24 private ValueExpression itemLabel;
25 private ValueExpression itemValue;
26 private ValueExpression itemDisabled;
27 private ValueExpression itemDescription;
28 private ValueExpression itemAccessKey;
29 private ValueExpression itemAcceleratorKey;
30 private ValueExpression itemGroupName;
31 private ValueExpression itemInputType;
32 private ValueExpression itemStyleClass;
33 private ValueExpression itemImageURL;
34 private ValueExpression itemDisabledImageURL;
35 private ValueExpression itemHoverImageURL;
36 private ValueExpression itemSelectedImageURL;
37 private ValueExpression itemExpandedImageURL;
38 private ValueExpression itemVisibility;
39 public String getComponentType() {
40 return SelectItemsIteratorComponent.COMPONENT_TYPE;
41 }
42
43 public final void setItems(ValueExpression items) {
44 this.items = items;
45 }
46
47 public final void setVar(ValueExpression var) {
48 this.var = var;
49 }
50
51 public final void setItemIndexVar(ValueExpression itemIndexVar) {
52 this.itemIndexVar = itemIndexVar;
53 }
54
55 public final void setItemLabel(ValueExpression itemLabel) {
56 this.itemLabel = itemLabel;
57 }
58
59 public final void setItemValue(ValueExpression itemValue) {
60 this.itemValue = itemValue;
61 }
62
63 public final void setItemDisabled(ValueExpression itemDisabled) {
64 this.itemDisabled = itemDisabled;
65 }
66
67 public final void setItemDescription(ValueExpression itemDescription) {
68 this.itemDescription = itemDescription;
69 }
70
71 public final void setItemAccessKey(ValueExpression itemAccessKey) {
72 this.itemAccessKey = itemAccessKey;
73 }
74
75 public final void setItemAcceleratorKey(ValueExpression itemAcceleratorKey) {
76 this.itemAcceleratorKey = itemAcceleratorKey;
77 }
78
79 public final void setItemGroupName(ValueExpression itemGroupName) {
80 this.itemGroupName = itemGroupName;
81 }
82
83 public final void setItemInputType(ValueExpression itemInputType) {
84 this.itemInputType = itemInputType;
85 }
86
87 public final void setItemStyleClass(ValueExpression itemStyleClass) {
88 this.itemStyleClass = itemStyleClass;
89 }
90
91 public final void setItemImageURL(ValueExpression itemImageURL) {
92 this.itemImageURL = itemImageURL;
93 }
94
95 public final void setItemDisabledImageURL(ValueExpression itemDisabledImageURL) {
96 this.itemDisabledImageURL = itemDisabledImageURL;
97 }
98
99 public final void setItemHoverImageURL(ValueExpression itemHoverImageURL) {
100 this.itemHoverImageURL = itemHoverImageURL;
101 }
102
103 public final void setItemSelectedImageURL(ValueExpression itemSelectedImageURL) {
104 this.itemSelectedImageURL = itemSelectedImageURL;
105 }
106
107 public final void setItemExpandedImageURL(ValueExpression itemExpandedImageURL) {
108 this.itemExpandedImageURL = itemExpandedImageURL;
109 }
110
111 public final void setItemVisibility(ValueExpression itemVisibility) {
112 this.itemVisibility = itemVisibility;
113 }
114
115 protected void setProperties(UIComponent uiComponent) {
116 if (LOG.isDebugEnabled()) {
117 if (SelectItemsIteratorComponent.COMPONENT_TYPE==getComponentType()) {
118 LOG.debug("Component id='"+getId()+"' type='"+getComponentType()+"'.");
119 }
120 LOG.debug(" items='"+items+"'");
121 LOG.debug(" var='"+var+"'");
122 LOG.debug(" itemIndexVar='"+itemIndexVar+"'");
123 LOG.debug(" itemLabel='"+itemLabel+"'");
124 LOG.debug(" itemValue='"+itemValue+"'");
125 LOG.debug(" itemDisabled='"+itemDisabled+"'");
126 LOG.debug(" itemDescription='"+itemDescription+"'");
127 LOG.debug(" itemAccessKey='"+itemAccessKey+"'");
128 LOG.debug(" itemAcceleratorKey='"+itemAcceleratorKey+"'");
129 LOG.debug(" itemGroupName='"+itemGroupName+"'");
130 LOG.debug(" itemInputType='"+itemInputType+"'");
131 LOG.debug(" itemStyleClass='"+itemStyleClass+"'");
132 LOG.debug(" itemImageURL='"+itemImageURL+"'");
133 LOG.debug(" itemDisabledImageURL='"+itemDisabledImageURL+"'");
134 LOG.debug(" itemHoverImageURL='"+itemHoverImageURL+"'");
135 LOG.debug(" itemSelectedImageURL='"+itemSelectedImageURL+"'");
136 LOG.debug(" itemExpandedImageURL='"+itemExpandedImageURL+"'");
137 LOG.debug(" itemVisibility='"+itemVisibility+"'");
138 }
139 if ((uiComponent instanceof SelectItemsIteratorComponent)==false) {
140 if (uiComponent instanceof UIViewRoot) {
141 throw new IllegalStateException("The first component of the page must be a UIViewRoot component !");
142 }
143 throw new IllegalStateException("Component specified by tag is not instanceof of 'SelectItemsIteratorComponent'.");
144 }
145
146 super.setProperties(uiComponent);
147
148 SelectItemsIteratorComponent component = (SelectItemsIteratorComponent) uiComponent;
149 FacesContext facesContext = getFacesContext();
150
151 if (items != null) {
152 if (items.isLiteralText()==false) {
153 component.setValueExpression(Properties.ITEMS, items);
154
155 } else {
156 throw new javax.faces.FacesException("Attribute 'items' accept only a binding expression !");
157 }
158 }
159
160 if (var != null) {
161 if (var.isLiteralText()==false) {
162 throw new javax.faces.FacesException("Attribute 'var' does not accept binding !");
163 }
164 component.setVar(var.getExpressionString());
165 }
166
167 if (itemIndexVar != null) {
168 if (itemIndexVar.isLiteralText()==false) {
169 throw new javax.faces.FacesException("Attribute 'itemIndexVar' does not accept binding !");
170 }
171 component.setItemIndexVar(itemIndexVar.getExpressionString());
172 }
173
174 if (itemLabel != null) {
175 if (itemLabel.isLiteralText()==false) {
176 component.setValueExpression(Properties.ITEM_LABEL, itemLabel);
177
178 } else {
179 component.setItemLabel(itemLabel.getExpressionString());
180 }
181 }
182
183 if (itemValue != null) {
184 if (itemValue.isLiteralText()==false) {
185 component.setValueExpression(Properties.ITEM_VALUE, itemValue);
186
187 } else {
188 component.setItemValue(itemValue.getExpressionString());
189 }
190 }
191
192 if (itemDisabled != null) {
193 if (itemDisabled.isLiteralText()==false) {
194 component.setValueExpression(Properties.ITEM_DISABLED, itemDisabled);
195
196 } else {
197 component.setItemDisabled(getBool(itemDisabled.getExpressionString()));
198 }
199 }
200
201 if (itemDescription != null) {
202 if (itemDescription.isLiteralText()==false) {
203 component.setValueExpression(Properties.ITEM_DESCRIPTION, itemDescription);
204
205 } else {
206 component.setItemDescription(itemDescription.getExpressionString());
207 }
208 }
209
210 if (itemAccessKey != null) {
211 if (itemAccessKey.isLiteralText()==false) {
212 component.setValueExpression(Properties.ITEM_ACCESS_KEY, itemAccessKey);
213
214 } else {
215 component.setItemAccessKey(itemAccessKey.getExpressionString());
216 }
217 }
218
219 if (itemAcceleratorKey != null) {
220 if (itemAcceleratorKey.isLiteralText()==false) {
221 component.setValueExpression(Properties.ITEM_ACCELERATOR_KEY, itemAcceleratorKey);
222
223 } else {
224 component.setItemAcceleratorKey(itemAcceleratorKey.getExpressionString());
225 }
226 }
227
228 if (itemGroupName != null) {
229 if (itemGroupName.isLiteralText()==false) {
230 component.setValueExpression(Properties.ITEM_GROUP_NAME, itemGroupName);
231
232 } else {
233 component.setItemGroupName(itemGroupName.getExpressionString());
234 }
235 }
236
237 if (itemInputType != null) {
238 if (itemInputType.isLiteralText()==false) {
239 component.setValueExpression(Properties.ITEM_INPUT_TYPE, itemInputType);
240
241 } else {
242 component.setItemInputType(itemInputType.getExpressionString());
243 }
244 }
245
246 if (itemStyleClass != null) {
247 if (itemStyleClass.isLiteralText()==false) {
248 component.setValueExpression(Properties.ITEM_STYLE_CLASS, itemStyleClass);
249
250 } else {
251 component.setItemStyleClass(itemStyleClass.getExpressionString());
252 }
253 }
254
255 if (itemImageURL != null) {
256 if (itemImageURL.isLiteralText()==false) {
257 component.setValueExpression(Properties.ITEM_IMAGE_URL, itemImageURL);
258
259 } else {
260 component.setItemImageURL(itemImageURL.getExpressionString());
261 }
262 }
263
264 if (itemDisabledImageURL != null) {
265 if (itemDisabledImageURL.isLiteralText()==false) {
266 component.setValueExpression(Properties.ITEM_DISABLED_IMAGE_URL, itemDisabledImageURL);
267
268 } else {
269 component.setItemDisabledImageURL(itemDisabledImageURL.getExpressionString());
270 }
271 }
272
273 if (itemHoverImageURL != null) {
274 if (itemHoverImageURL.isLiteralText()==false) {
275 component.setValueExpression(Properties.ITEM_HOVER_IMAGE_URL, itemHoverImageURL);
276
277 } else {
278 component.setItemHoverImageURL(itemHoverImageURL.getExpressionString());
279 }
280 }
281
282 if (itemSelectedImageURL != null) {
283 if (itemSelectedImageURL.isLiteralText()==false) {
284 component.setValueExpression(Properties.ITEM_SELECTED_IMAGE_URL, itemSelectedImageURL);
285
286 } else {
287 component.setItemSelectedImageURL(itemSelectedImageURL.getExpressionString());
288 }
289 }
290
291 if (itemExpandedImageURL != null) {
292 if (itemExpandedImageURL.isLiteralText()==false) {
293 component.setValueExpression(Properties.ITEM_EXPANDED_IMAGE_URL, itemExpandedImageURL);
294
295 } else {
296 component.setItemExpandedImageURL(itemExpandedImageURL.getExpressionString());
297 }
298 }
299
300 if (itemVisibility != null) {
301 if (itemVisibility.isLiteralText()==false) {
302 component.setValueExpression(Properties.ITEM_VISIBILITY, itemVisibility);
303
304 } else {
305 component.setItemVisibility(getBool(itemVisibility.getExpressionString()));
306 }
307 }
308 }
309
310 public void release() {
311 items = null;
312 var = null;
313 itemIndexVar = null;
314 itemLabel = null;
315 itemValue = null;
316 itemDisabled = null;
317 itemDescription = null;
318 itemAccessKey = null;
319 itemAcceleratorKey = null;
320 itemGroupName = null;
321 itemInputType = null;
322 itemStyleClass = null;
323 itemImageURL = null;
324 itemDisabledImageURL = null;
325 itemHoverImageURL = null;
326 itemSelectedImageURL = null;
327 itemExpandedImageURL = null;
328 itemVisibility = null;
329
330 super.release();
331 }
332
333 }