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