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.component.ComboColumnComponent;
6 import org.rcfaces.core.internal.component.Properties;
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 ComboColumnTag extends CameliaTag implements Tag {
17
18
19 private static final Log LOG=LogFactory.getLog(ComboColumnTag.class);
20
21 private ValueExpression visible;
22 private ValueExpression hiddenMode;
23 private ValueExpression text;
24 private ValueExpression textDirection;
25 private ValueExpression toolTipText;
26 private ValueExpression alignment;
27 private ValueExpression backgroundColor;
28 private ValueExpression foregroundColor;
29 private ValueExpression sortListeners;
30 private ValueExpression styleClass;
31 private ValueExpression ascending;
32 private ValueExpression sortComparator;
33 private ValueExpression resizable;
34 private ValueExpression disabledImageURL;
35 private ValueExpression hoverImageURL;
36 private ValueExpression selectedImageURL;
37 private ValueExpression imageURL;
38 private ValueExpression imageHeight;
39 private ValueExpression imageWidth;
40 private ValueExpression maxWidth;
41 private ValueExpression minWidth;
42 private ValueExpression width;
43 private ValueExpression verticalAlignment;
44 private ValueExpression autoFilter;
45 private ValueExpression cellImageURL;
46 private ValueExpression defaultCellImageURL;
47 private ValueExpression cellStyleClass;
48 private ValueExpression defaultCellStyleClass;
49 private ValueExpression cellDefaultToolTipText;
50 private ValueExpression cellToolTipText;
51 private ValueExpression selectionListeners;
52 private ValueExpression doubleClickListeners;
53 private ValueExpression userEventListeners;
54 private ValueExpression initListeners;
55 private ValueExpression value;
56 private ValueExpression converter;
57
58 public String getComponentType() {
59 return ComboColumnComponent.COMPONENT_TYPE;
60 }
61
62 public final void setVisible(ValueExpression visible) {
63 this.visible = visible;
64 }
65
66 public final void setHiddenMode(ValueExpression hiddenMode) {
67 this.hiddenMode = hiddenMode;
68 }
69
70 public final void setText(ValueExpression text) {
71 this.text = text;
72 }
73
74 public final void setTextDirection(ValueExpression textDirection) {
75 this.textDirection = textDirection;
76 }
77
78 public final void setToolTipText(ValueExpression toolTipText) {
79 this.toolTipText = toolTipText;
80 }
81
82 public final void setAlignment(ValueExpression alignment) {
83 this.alignment = alignment;
84 }
85
86 public final void setBackgroundColor(ValueExpression backgroundColor) {
87 this.backgroundColor = backgroundColor;
88 }
89
90 public final void setForegroundColor(ValueExpression foregroundColor) {
91 this.foregroundColor = foregroundColor;
92 }
93
94 public final void setSortListener(ValueExpression sortListeners) {
95 this.sortListeners = sortListeners;
96 }
97
98 public final void setStyleClass(ValueExpression styleClass) {
99 this.styleClass = styleClass;
100 }
101
102 public final void setAscending(ValueExpression ascending) {
103 this.ascending = ascending;
104 }
105
106 public final void setSortComparator(ValueExpression sortComparator) {
107 this.sortComparator = sortComparator;
108 }
109
110 public final void setResizable(ValueExpression resizable) {
111 this.resizable = resizable;
112 }
113
114 public final void setDisabledImageURL(ValueExpression disabledImageURL) {
115 this.disabledImageURL = disabledImageURL;
116 }
117
118 public final void setHoverImageURL(ValueExpression hoverImageURL) {
119 this.hoverImageURL = hoverImageURL;
120 }
121
122 public final void setSelectedImageURL(ValueExpression selectedImageURL) {
123 this.selectedImageURL = selectedImageURL;
124 }
125
126 public final void setImageURL(ValueExpression imageURL) {
127 this.imageURL = imageURL;
128 }
129
130 public final void setImageHeight(ValueExpression imageHeight) {
131 this.imageHeight = imageHeight;
132 }
133
134 public final void setImageWidth(ValueExpression imageWidth) {
135 this.imageWidth = imageWidth;
136 }
137
138 public final void setMaxWidth(ValueExpression maxWidth) {
139 this.maxWidth = maxWidth;
140 }
141
142 public final void setMinWidth(ValueExpression minWidth) {
143 this.minWidth = minWidth;
144 }
145
146 public final void setWidth(ValueExpression width) {
147 this.width = width;
148 }
149
150 public final void setVerticalAlignment(ValueExpression verticalAlignment) {
151 this.verticalAlignment = verticalAlignment;
152 }
153
154 public final void setAutoFilter(ValueExpression autoFilter) {
155 this.autoFilter = autoFilter;
156 }
157
158 public final void setCellImageURL(ValueExpression cellImageURL) {
159 this.cellImageURL = cellImageURL;
160 }
161
162 public final void setDefaultCellImageURL(ValueExpression defaultCellImageURL) {
163 this.defaultCellImageURL = defaultCellImageURL;
164 }
165
166 public final void setCellStyleClass(ValueExpression cellStyleClass) {
167 this.cellStyleClass = cellStyleClass;
168 }
169
170 public final void setDefaultCellStyleClass(ValueExpression defaultCellStyleClass) {
171 this.defaultCellStyleClass = defaultCellStyleClass;
172 }
173
174 public final void setCellDefaultToolTipText(ValueExpression cellDefaultToolTipText) {
175 this.cellDefaultToolTipText = cellDefaultToolTipText;
176 }
177
178 public final void setCellToolTipText(ValueExpression cellToolTipText) {
179 this.cellToolTipText = cellToolTipText;
180 }
181
182 public final void setSelectionListener(ValueExpression selectionListeners) {
183 this.selectionListeners = selectionListeners;
184 }
185
186 public final void setDoubleClickListener(ValueExpression doubleClickListeners) {
187 this.doubleClickListeners = doubleClickListeners;
188 }
189
190 public final void setUserEventListener(ValueExpression userEventListeners) {
191 this.userEventListeners = userEventListeners;
192 }
193
194 public final void setInitListener(ValueExpression initListeners) {
195 this.initListeners = initListeners;
196 }
197
198 public final void setValue(ValueExpression value) {
199 this.value = value;
200 }
201
202 public final void setConverter(ValueExpression converter) {
203 this.converter=converter;
204 }
205
206 protected void setProperties(UIComponent uiComponent) {
207 if (LOG.isDebugEnabled()) {
208 if (ComboColumnComponent.COMPONENT_TYPE==getComponentType()) {
209 LOG.debug("Component id='"+getId()+"' type='"+getComponentType()+"'.");
210 }
211 LOG.debug(" visible='"+visible+"'");
212 LOG.debug(" hiddenMode='"+hiddenMode+"'");
213 LOG.debug(" text='"+text+"'");
214 LOG.debug(" textDirection='"+textDirection+"'");
215 LOG.debug(" toolTipText='"+toolTipText+"'");
216 LOG.debug(" alignment='"+alignment+"'");
217 LOG.debug(" backgroundColor='"+backgroundColor+"'");
218 LOG.debug(" foregroundColor='"+foregroundColor+"'");
219 LOG.debug(" styleClass='"+styleClass+"'");
220 LOG.debug(" ascending='"+ascending+"'");
221 LOG.debug(" sortComparator='"+sortComparator+"'");
222 LOG.debug(" resizable='"+resizable+"'");
223 LOG.debug(" disabledImageURL='"+disabledImageURL+"'");
224 LOG.debug(" hoverImageURL='"+hoverImageURL+"'");
225 LOG.debug(" selectedImageURL='"+selectedImageURL+"'");
226 LOG.debug(" imageURL='"+imageURL+"'");
227 LOG.debug(" imageHeight='"+imageHeight+"'");
228 LOG.debug(" imageWidth='"+imageWidth+"'");
229 LOG.debug(" maxWidth='"+maxWidth+"'");
230 LOG.debug(" minWidth='"+minWidth+"'");
231 LOG.debug(" width='"+width+"'");
232 LOG.debug(" verticalAlignment='"+verticalAlignment+"'");
233 LOG.debug(" autoFilter='"+autoFilter+"'");
234 LOG.debug(" cellImageURL='"+cellImageURL+"'");
235 LOG.debug(" defaultCellImageURL='"+defaultCellImageURL+"'");
236 LOG.debug(" cellStyleClass='"+cellStyleClass+"'");
237 LOG.debug(" defaultCellStyleClass='"+defaultCellStyleClass+"'");
238 LOG.debug(" cellDefaultToolTipText='"+cellDefaultToolTipText+"'");
239 LOG.debug(" cellToolTipText='"+cellToolTipText+"'");
240 LOG.debug(" value='"+value+"'");
241 }
242 if ((uiComponent instanceof ComboColumnComponent)==false) {
243 if (uiComponent instanceof UIViewRoot) {
244 throw new IllegalStateException("The first component of the page must be a UIViewRoot component !");
245 }
246 throw new IllegalStateException("Component specified by tag is not instanceof of 'ComboColumnComponent'.");
247 }
248
249 super.setProperties(uiComponent);
250
251 ComboColumnComponent component = (ComboColumnComponent) uiComponent;
252 FacesContext facesContext = getFacesContext();
253 Application application = facesContext.getApplication();
254
255 if (visible != null) {
256 if (visible.isLiteralText()==false) {
257 component.setValueExpression(Properties.VISIBLE, visible);
258
259 } else {
260 component.setVisible(getBool(visible.getExpressionString()));
261 }
262 }
263
264 if (hiddenMode != null) {
265 if (hiddenMode.isLiteralText()==false) {
266 component.setValueExpression(Properties.HIDDEN_MODE, hiddenMode);
267
268 } else {
269 component.setHiddenMode(hiddenMode.getExpressionString());
270 }
271 }
272
273 if (text != null) {
274 if (text.isLiteralText()==false) {
275 component.setValueExpression(Properties.TEXT, text);
276
277 } else {
278 component.setText(text.getExpressionString());
279 }
280 }
281
282 if (textDirection != null) {
283 if (textDirection.isLiteralText()==false) {
284 component.setValueExpression(Properties.TEXT_DIRECTION, textDirection);
285
286 } else {
287 component.setTextDirection(getInt(textDirection.getExpressionString()));
288 }
289 }
290
291 if (toolTipText != null) {
292 if (toolTipText.isLiteralText()==false) {
293 component.setValueExpression(Properties.TOOL_TIP_TEXT, toolTipText);
294
295 } else {
296 component.setToolTipText(toolTipText.getExpressionString());
297 }
298 }
299
300 if (alignment != null) {
301 if (alignment.isLiteralText()==false) {
302 component.setValueExpression(Properties.ALIGNMENT, alignment);
303
304 } else {
305 component.setAlignment(alignment.getExpressionString());
306 }
307 }
308
309 if (backgroundColor != null) {
310 if (backgroundColor.isLiteralText()==false) {
311 component.setValueExpression(Properties.BACKGROUND_COLOR, backgroundColor);
312
313 } else {
314 component.setBackgroundColor(backgroundColor.getExpressionString());
315 }
316 }
317
318 if (foregroundColor != null) {
319 if (foregroundColor.isLiteralText()==false) {
320 component.setValueExpression(Properties.FOREGROUND_COLOR, foregroundColor);
321
322 } else {
323 component.setForegroundColor(foregroundColor.getExpressionString());
324 }
325 }
326
327 if (sortListeners != null) {
328 ListenersTools1_2.parseListener(facesContext, component, ListenersTools.SORT_LISTENER_TYPE, sortListeners);
329 }
330
331 if (styleClass != null) {
332 if (styleClass.isLiteralText()==false) {
333 component.setValueExpression(Properties.STYLE_CLASS, styleClass);
334
335 } else {
336 component.setStyleClass(styleClass.getExpressionString());
337 }
338 }
339
340 if (ascending != null) {
341 if (ascending.isLiteralText()==false) {
342 component.setValueExpression(Properties.ASCENDING, ascending);
343
344 } else {
345 component.setAscending(getBool(ascending.getExpressionString()));
346 }
347 }
348
349 if (sortComparator != null) {
350 component.setValueExpression(Properties.SORT_COMPARATOR, sortComparator);
351 }
352
353 if (resizable != null) {
354 if (resizable.isLiteralText()==false) {
355 component.setValueExpression(Properties.RESIZABLE, resizable);
356
357 } else {
358 component.setResizable(getBool(resizable.getExpressionString()));
359 }
360 }
361
362 if (disabledImageURL != null) {
363 if (disabledImageURL.isLiteralText()==false) {
364 component.setValueExpression(Properties.DISABLED_IMAGE_URL, disabledImageURL);
365
366 } else {
367 component.setDisabledImageURL(disabledImageURL.getExpressionString());
368 }
369 }
370
371 if (hoverImageURL != null) {
372 if (hoverImageURL.isLiteralText()==false) {
373 component.setValueExpression(Properties.HOVER_IMAGE_URL, hoverImageURL);
374
375 } else {
376 component.setHoverImageURL(hoverImageURL.getExpressionString());
377 }
378 }
379
380 if (selectedImageURL != null) {
381 if (selectedImageURL.isLiteralText()==false) {
382 component.setValueExpression(Properties.SELECTED_IMAGE_URL, selectedImageURL);
383
384 } else {
385 component.setSelectedImageURL(selectedImageURL.getExpressionString());
386 }
387 }
388
389 if (imageURL != null) {
390 if (imageURL.isLiteralText()==false) {
391 component.setValueExpression(Properties.IMAGE_URL, imageURL);
392
393 } else {
394 component.setImageURL(imageURL.getExpressionString());
395 }
396 }
397
398 if (imageHeight != null) {
399 if (imageHeight.isLiteralText()==false) {
400 component.setValueExpression(Properties.IMAGE_HEIGHT, imageHeight);
401
402 } else {
403 component.setImageHeight(getInt(imageHeight.getExpressionString()));
404 }
405 }
406
407 if (imageWidth != null) {
408 if (imageWidth.isLiteralText()==false) {
409 component.setValueExpression(Properties.IMAGE_WIDTH, imageWidth);
410
411 } else {
412 component.setImageWidth(getInt(imageWidth.getExpressionString()));
413 }
414 }
415
416 if (maxWidth != null) {
417 if (maxWidth.isLiteralText()==false) {
418 component.setValueExpression(Properties.MAX_WIDTH, maxWidth);
419
420 } else {
421 component.setMaxWidth(getInt(maxWidth.getExpressionString()));
422 }
423 }
424
425 if (minWidth != null) {
426 if (minWidth.isLiteralText()==false) {
427 component.setValueExpression(Properties.MIN_WIDTH, minWidth);
428
429 } else {
430 component.setMinWidth(getInt(minWidth.getExpressionString()));
431 }
432 }
433
434 if (width != null) {
435 if (width.isLiteralText()==false) {
436 component.setValueExpression(Properties.WIDTH, width);
437
438 } else {
439 component.setWidth(width.getExpressionString());
440 }
441 }
442
443 if (verticalAlignment != null) {
444 if (verticalAlignment.isLiteralText()==false) {
445 component.setValueExpression(Properties.VERTICAL_ALIGNMENT, verticalAlignment);
446
447 } else {
448 component.setVerticalAlignment(verticalAlignment.getExpressionString());
449 }
450 }
451
452 if (autoFilter != null) {
453 if (autoFilter.isLiteralText()==false) {
454 component.setValueExpression(Properties.AUTO_FILTER, autoFilter);
455
456 } else {
457 component.setAutoFilter(getBool(autoFilter.getExpressionString()));
458 }
459 }
460
461 if (cellImageURL != null) {
462 if (cellImageURL.isLiteralText()==false) {
463 component.setValueExpression(Properties.CELL_IMAGE_URL, cellImageURL);
464
465 } else {
466 component.setCellImageURL(cellImageURL.getExpressionString());
467 }
468 }
469
470 if (defaultCellImageURL != null) {
471 if (defaultCellImageURL.isLiteralText()==false) {
472 component.setValueExpression(Properties.DEFAULT_CELL_IMAGE_URL, defaultCellImageURL);
473
474 } else {
475 component.setDefaultCellImageURL(defaultCellImageURL.getExpressionString());
476 }
477 }
478
479 if (cellStyleClass != null) {
480 if (cellStyleClass.isLiteralText()==false) {
481 component.setValueExpression(Properties.CELL_STYLE_CLASS, cellStyleClass);
482
483 } else {
484 component.setCellStyleClass(cellStyleClass.getExpressionString());
485 }
486 }
487
488 if (defaultCellStyleClass != null) {
489 if (defaultCellStyleClass.isLiteralText()==false) {
490 component.setValueExpression(Properties.DEFAULT_CELL_STYLE_CLASS, defaultCellStyleClass);
491
492 } else {
493 component.setDefaultCellStyleClass(defaultCellStyleClass.getExpressionString());
494 }
495 }
496
497 if (cellDefaultToolTipText != null) {
498 if (cellDefaultToolTipText.isLiteralText()==false) {
499 component.setValueExpression(Properties.CELL_DEFAULT_TOOL_TIP_TEXT, cellDefaultToolTipText);
500
501 } else {
502 component.setCellDefaultToolTipText(cellDefaultToolTipText.getExpressionString());
503 }
504 }
505
506 if (cellToolTipText != null) {
507 if (cellToolTipText.isLiteralText()==false) {
508 component.setValueExpression(Properties.CELL_TOOL_TIP_TEXT, cellToolTipText);
509
510 } else {
511 component.setCellToolTipText(cellToolTipText.getExpressionString());
512 }
513 }
514
515 if (selectionListeners != null) {
516 ListenersTools1_2.parseListener(facesContext, component, ListenersTools.SELECTION_LISTENER_TYPE, selectionListeners);
517 }
518
519 if (doubleClickListeners != null) {
520 ListenersTools1_2.parseListener(facesContext, component, ListenersTools.DOUBLE_CLICK_LISTENER_TYPE, doubleClickListeners);
521 }
522
523 if (userEventListeners != null) {
524 ListenersTools1_2.parseListener(facesContext, component, ListenersTools.USER_EVENT_LISTENER_TYPE, userEventListeners);
525 }
526
527 if (initListeners != null) {
528 ListenersTools1_2.parseListener(facesContext, component, ListenersTools.INIT_LISTENER_TYPE, initListeners);
529 }
530
531 if (value != null) {
532 if (value.isLiteralText()==false) {
533 component.setValueExpression(Properties.VALUE, value);
534
535 } else {
536 component.setValue(value.getExpressionString());
537 }
538 }
539 if (converter != null) {
540 if (converter.isLiteralText()==false) {
541 component.setValueExpression(Properties.CONVERTER, converter);
542 } else {
543 component.setConverter(application.createConverter(converter.getExpressionString()));
544 }
545 }
546 }
547
548 public void release() {
549 visible = null;
550 hiddenMode = null;
551 text = null;
552 textDirection = null;
553 toolTipText = null;
554 alignment = null;
555 backgroundColor = null;
556 foregroundColor = null;
557 sortListeners = null;
558 styleClass = null;
559 ascending = null;
560 sortComparator = null;
561 resizable = null;
562 disabledImageURL = null;
563 hoverImageURL = null;
564 selectedImageURL = null;
565 imageURL = null;
566 imageHeight = null;
567 imageWidth = null;
568 maxWidth = null;
569 minWidth = null;
570 width = null;
571 verticalAlignment = null;
572 autoFilter = null;
573 cellImageURL = null;
574 defaultCellImageURL = null;
575 cellStyleClass = null;
576 defaultCellStyleClass = null;
577 cellDefaultToolTipText = null;
578 cellToolTipText = null;
579 selectionListeners = null;
580 doubleClickListeners = null;
581 userEventListeners = null;
582 initListeners = null;
583 value = null;
584 converter = null;
585
586 super.release();
587 }
588
589 }