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.AbstractGridComponent;
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 AbstractGridTag extends CameliaTag implements Tag {
17
18
19 private static final Log LOG=LogFactory.getLog(AbstractGridTag.class);
20
21 private ValueExpression helpMessage;
22 private ValueExpression helpURL;
23 private ValueExpression toolTipText;
24 private ValueExpression blurListeners;
25 private ValueExpression focusListeners;
26 private ValueExpression backgroundColor;
27 private ValueExpression foregroundColor;
28 private ValueExpression visible;
29 private ValueExpression errorListeners;
30 private ValueExpression sortManager;
31 private ValueExpression mouseOutListeners;
32 private ValueExpression mouseOverListeners;
33 private ValueExpression tabIndex;
34 private ValueExpression unlockedClientAttributeNames;
35 private ValueExpression propertyChangeListeners;
36 private ValueExpression marginBottom;
37 private ValueExpression marginLeft;
38 private ValueExpression marginRight;
39 private ValueExpression marginTop;
40 private ValueExpression keyUpListeners;
41 private ValueExpression keyDownListeners;
42 private ValueExpression keyPressListeners;
43 private ValueExpression resetListeners;
44 private ValueExpression userEventListeners;
45 private ValueExpression x;
46 private ValueExpression y;
47 private ValueExpression partialRendering;
48 private ValueExpression lookId;
49 private ValueExpression styleClass;
50 private ValueExpression width;
51 private ValueExpression height;
52 private ValueExpression ariaLabel;
53 private ValueExpression ariaLevel;
54 private ValueExpression waiRole;
55 private ValueExpression bottom;
56 private ValueExpression left;
57 private ValueExpression right;
58 private ValueExpression top;
59 private ValueExpression initListeners;
60 private ValueExpression hiddenMode;
61 private ValueExpression margins;
62 private ValueExpression rows;
63 private ValueExpression first;
64 private ValueExpression var;
65 private ValueExpression value;
66 public final void setHelpMessage(ValueExpression helpMessage) {
67 this.helpMessage = helpMessage;
68 }
69
70 public final void setHelpURL(ValueExpression helpURL) {
71 this.helpURL = helpURL;
72 }
73
74 public final void setToolTipText(ValueExpression toolTipText) {
75 this.toolTipText = toolTipText;
76 }
77
78 public final void setBlurListener(ValueExpression blurListeners) {
79 this.blurListeners = blurListeners;
80 }
81
82 public final void setFocusListener(ValueExpression focusListeners) {
83 this.focusListeners = focusListeners;
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 setVisible(ValueExpression visible) {
95 this.visible = visible;
96 }
97
98 public final void setErrorListener(ValueExpression errorListeners) {
99 this.errorListeners = errorListeners;
100 }
101
102 public final void setSortManager(ValueExpression sortManager) {
103 this.sortManager = sortManager;
104 }
105
106 public final void setMouseOutListener(ValueExpression mouseOutListeners) {
107 this.mouseOutListeners = mouseOutListeners;
108 }
109
110 public final void setMouseOverListener(ValueExpression mouseOverListeners) {
111 this.mouseOverListeners = mouseOverListeners;
112 }
113
114 public final void setTabIndex(ValueExpression tabIndex) {
115 this.tabIndex = tabIndex;
116 }
117
118 public final void setUnlockedClientAttributeNames(ValueExpression unlockedClientAttributeNames) {
119 this.unlockedClientAttributeNames = unlockedClientAttributeNames;
120 }
121
122 public final void setPropertyChangeListener(ValueExpression propertyChangeListeners) {
123 this.propertyChangeListeners = propertyChangeListeners;
124 }
125
126 public final void setMarginBottom(ValueExpression marginBottom) {
127 this.marginBottom = marginBottom;
128 }
129
130 public final void setMarginLeft(ValueExpression marginLeft) {
131 this.marginLeft = marginLeft;
132 }
133
134 public final void setMarginRight(ValueExpression marginRight) {
135 this.marginRight = marginRight;
136 }
137
138 public final void setMarginTop(ValueExpression marginTop) {
139 this.marginTop = marginTop;
140 }
141
142 public final void setKeyUpListener(ValueExpression keyUpListeners) {
143 this.keyUpListeners = keyUpListeners;
144 }
145
146 public final void setKeyDownListener(ValueExpression keyDownListeners) {
147 this.keyDownListeners = keyDownListeners;
148 }
149
150 public final void setKeyPressListener(ValueExpression keyPressListeners) {
151 this.keyPressListeners = keyPressListeners;
152 }
153
154 public final void setResetListener(ValueExpression resetListeners) {
155 this.resetListeners = resetListeners;
156 }
157
158 public final void setUserEventListener(ValueExpression userEventListeners) {
159 this.userEventListeners = userEventListeners;
160 }
161
162 public final void setX(ValueExpression x) {
163 this.x = x;
164 }
165
166 public final void setY(ValueExpression y) {
167 this.y = y;
168 }
169
170 public final void setPartialRendering(ValueExpression partialRendering) {
171 this.partialRendering = partialRendering;
172 }
173
174 public final void setLookId(ValueExpression lookId) {
175 this.lookId = lookId;
176 }
177
178 public final void setStyleClass(ValueExpression styleClass) {
179 this.styleClass = styleClass;
180 }
181
182 public final void setWidth(ValueExpression width) {
183 this.width = width;
184 }
185
186 public final void setHeight(ValueExpression height) {
187 this.height = height;
188 }
189
190 public final void setAriaLabel(ValueExpression ariaLabel) {
191 this.ariaLabel = ariaLabel;
192 }
193
194 public final void setAriaLevel(ValueExpression ariaLevel) {
195 this.ariaLevel = ariaLevel;
196 }
197
198 public final void setWaiRole(ValueExpression waiRole) {
199 this.waiRole = waiRole;
200 }
201
202 public final void setBottom(ValueExpression bottom) {
203 this.bottom = bottom;
204 }
205
206 public final void setLeft(ValueExpression left) {
207 this.left = left;
208 }
209
210 public final void setRight(ValueExpression right) {
211 this.right = right;
212 }
213
214 public final void setTop(ValueExpression top) {
215 this.top = top;
216 }
217
218 public final void setInitListener(ValueExpression initListeners) {
219 this.initListeners = initListeners;
220 }
221
222 public final void setHiddenMode(ValueExpression hiddenMode) {
223 this.hiddenMode = hiddenMode;
224 }
225
226 public final void setMargins(ValueExpression margins) {
227 this.margins = margins;
228 }
229
230 public final void setRows(ValueExpression rows) {
231 this.rows = rows;
232 }
233
234 public final void setFirst(ValueExpression first) {
235 this.first = first;
236 }
237
238 public final void setVar(ValueExpression var) {
239 this.var = var;
240 }
241
242 public final void setValue(ValueExpression value) {
243 this.value = value;
244 }
245
246 protected void setProperties(UIComponent uiComponent) {
247 if (LOG.isDebugEnabled()) {
248 LOG.debug(" helpMessage='"+helpMessage+"'");
249 LOG.debug(" helpURL='"+helpURL+"'");
250 LOG.debug(" toolTipText='"+toolTipText+"'");
251 LOG.debug(" backgroundColor='"+backgroundColor+"'");
252 LOG.debug(" foregroundColor='"+foregroundColor+"'");
253 LOG.debug(" visible='"+visible+"'");
254 LOG.debug(" sortManager='"+sortManager+"'");
255 LOG.debug(" tabIndex='"+tabIndex+"'");
256 LOG.debug(" unlockedClientAttributeNames='"+unlockedClientAttributeNames+"'");
257 LOG.debug(" marginBottom='"+marginBottom+"'");
258 LOG.debug(" marginLeft='"+marginLeft+"'");
259 LOG.debug(" marginRight='"+marginRight+"'");
260 LOG.debug(" marginTop='"+marginTop+"'");
261 LOG.debug(" x='"+x+"'");
262 LOG.debug(" y='"+y+"'");
263 LOG.debug(" partialRendering='"+partialRendering+"'");
264 LOG.debug(" lookId='"+lookId+"'");
265 LOG.debug(" styleClass='"+styleClass+"'");
266 LOG.debug(" width='"+width+"'");
267 LOG.debug(" height='"+height+"'");
268 LOG.debug(" ariaLabel='"+ariaLabel+"'");
269 LOG.debug(" ariaLevel='"+ariaLevel+"'");
270 LOG.debug(" waiRole='"+waiRole+"'");
271 LOG.debug(" bottom='"+bottom+"'");
272 LOG.debug(" left='"+left+"'");
273 LOG.debug(" right='"+right+"'");
274 LOG.debug(" top='"+top+"'");
275 LOG.debug(" hiddenMode='"+hiddenMode+"'");
276 LOG.debug(" margins='"+margins+"'");
277 LOG.debug(" rows='"+rows+"'");
278 LOG.debug(" first='"+first+"'");
279 LOG.debug(" var='"+var+"'");
280 }
281 if ((uiComponent instanceof AbstractGridComponent)==false) {
282 if (uiComponent instanceof UIViewRoot) {
283 throw new IllegalStateException("The first component of the page must be a UIViewRoot component !");
284 }
285 throw new IllegalStateException("Component specified by tag is not instanceof of 'AbstractGridComponent'.");
286 }
287
288 super.setProperties(uiComponent);
289
290 AbstractGridComponent component = (AbstractGridComponent) uiComponent;
291 FacesContext facesContext = getFacesContext();
292
293 if (helpMessage != null) {
294 if (helpMessage.isLiteralText()==false) {
295 component.setValueExpression(Properties.HELP_MESSAGE, helpMessage);
296
297 } else {
298 component.setHelpMessage(helpMessage.getExpressionString());
299 }
300 }
301
302 if (helpURL != null) {
303 if (helpURL.isLiteralText()==false) {
304 component.setValueExpression(Properties.HELP_URL, helpURL);
305
306 } else {
307 component.setHelpURL(helpURL.getExpressionString());
308 }
309 }
310
311 if (toolTipText != null) {
312 if (toolTipText.isLiteralText()==false) {
313 component.setValueExpression(Properties.TOOL_TIP_TEXT, toolTipText);
314
315 } else {
316 component.setToolTipText(toolTipText.getExpressionString());
317 }
318 }
319
320 if (blurListeners != null) {
321 ListenersTools1_2.parseListener(facesContext, component, ListenersTools.BLUR_LISTENER_TYPE, blurListeners);
322 }
323
324 if (focusListeners != null) {
325 ListenersTools1_2.parseListener(facesContext, component, ListenersTools.FOCUS_LISTENER_TYPE, focusListeners);
326 }
327
328 if (backgroundColor != null) {
329 if (backgroundColor.isLiteralText()==false) {
330 component.setValueExpression(Properties.BACKGROUND_COLOR, backgroundColor);
331
332 } else {
333 component.setBackgroundColor(backgroundColor.getExpressionString());
334 }
335 }
336
337 if (foregroundColor != null) {
338 if (foregroundColor.isLiteralText()==false) {
339 component.setValueExpression(Properties.FOREGROUND_COLOR, foregroundColor);
340
341 } else {
342 component.setForegroundColor(foregroundColor.getExpressionString());
343 }
344 }
345
346 if (visible != null) {
347 if (visible.isLiteralText()==false) {
348 component.setValueExpression(Properties.VISIBLE, visible);
349
350 } else {
351 component.setVisible(getBool(visible.getExpressionString()));
352 }
353 }
354
355 if (errorListeners != null) {
356 ListenersTools1_2.parseListener(facesContext, component, ListenersTools.ERROR_LISTENER_TYPE, errorListeners);
357 }
358
359 if (sortManager != null) {
360 if (sortManager.isLiteralText()==false) {
361 component.setValueExpression(Properties.SORT_MANAGER, sortManager);
362
363 } else {
364 component.setSortManager(sortManager.getExpressionString());
365 }
366 }
367
368 if (mouseOutListeners != null) {
369 ListenersTools1_2.parseListener(facesContext, component, ListenersTools.MOUSE_OUT_LISTENER_TYPE, mouseOutListeners);
370 }
371
372 if (mouseOverListeners != null) {
373 ListenersTools1_2.parseListener(facesContext, component, ListenersTools.MOUSE_OVER_LISTENER_TYPE, mouseOverListeners);
374 }
375
376 if (tabIndex != null) {
377 if (tabIndex.isLiteralText()==false) {
378 component.setValueExpression(Properties.TAB_INDEX, tabIndex);
379
380 } else {
381 component.setTabIndex(getInteger(tabIndex.getExpressionString()));
382 }
383 }
384
385 if (unlockedClientAttributeNames != null) {
386 if (unlockedClientAttributeNames.isLiteralText()==false) {
387 component.setValueExpression(Properties.UNLOCKED_CLIENT_ATTRIBUTE_NAMES, unlockedClientAttributeNames);
388
389 } else {
390 component.setUnlockedClientAttributeNames(unlockedClientAttributeNames.getExpressionString());
391 }
392 }
393
394 if (propertyChangeListeners != null) {
395 ListenersTools1_2.parseListener(facesContext, component, ListenersTools.PROPERTY_CHANGE_LISTENER_TYPE, propertyChangeListeners);
396 }
397
398 if (marginBottom != null) {
399 if (marginBottom.isLiteralText()==false) {
400 component.setValueExpression(Properties.MARGIN_BOTTOM, marginBottom);
401
402 } else {
403 component.setMarginBottom(marginBottom.getExpressionString());
404 }
405 }
406
407 if (marginLeft != null) {
408 if (marginLeft.isLiteralText()==false) {
409 component.setValueExpression(Properties.MARGIN_LEFT, marginLeft);
410
411 } else {
412 component.setMarginLeft(marginLeft.getExpressionString());
413 }
414 }
415
416 if (marginRight != null) {
417 if (marginRight.isLiteralText()==false) {
418 component.setValueExpression(Properties.MARGIN_RIGHT, marginRight);
419
420 } else {
421 component.setMarginRight(marginRight.getExpressionString());
422 }
423 }
424
425 if (marginTop != null) {
426 if (marginTop.isLiteralText()==false) {
427 component.setValueExpression(Properties.MARGIN_TOP, marginTop);
428
429 } else {
430 component.setMarginTop(marginTop.getExpressionString());
431 }
432 }
433
434 if (keyUpListeners != null) {
435 ListenersTools1_2.parseListener(facesContext, component, ListenersTools.KEY_UP_LISTENER_TYPE, keyUpListeners);
436 }
437
438 if (keyDownListeners != null) {
439 ListenersTools1_2.parseListener(facesContext, component, ListenersTools.KEY_DOWN_LISTENER_TYPE, keyDownListeners);
440 }
441
442 if (keyPressListeners != null) {
443 ListenersTools1_2.parseListener(facesContext, component, ListenersTools.KEY_PRESS_LISTENER_TYPE, keyPressListeners);
444 }
445
446 if (resetListeners != null) {
447 ListenersTools1_2.parseListener(facesContext, component, ListenersTools.RESET_LISTENER_TYPE, resetListeners);
448 }
449
450 if (userEventListeners != null) {
451 ListenersTools1_2.parseListener(facesContext, component, ListenersTools.USER_EVENT_LISTENER_TYPE, userEventListeners);
452 }
453
454 if (x != null) {
455 if (x.isLiteralText()==false) {
456 component.setValueExpression(Properties.X, x);
457
458 } else {
459 component.setX(x.getExpressionString());
460 }
461 }
462
463 if (y != null) {
464 if (y.isLiteralText()==false) {
465 component.setValueExpression(Properties.Y, y);
466
467 } else {
468 component.setY(y.getExpressionString());
469 }
470 }
471
472 if (partialRendering != null) {
473 if (partialRendering.isLiteralText()==false) {
474 component.setValueExpression(Properties.PARTIAL_RENDERING, partialRendering);
475
476 } else {
477 component.setPartialRendering(getBool(partialRendering.getExpressionString()));
478 }
479 }
480
481 if (lookId != null) {
482 if (lookId.isLiteralText()==false) {
483 component.setValueExpression(Properties.LOOK_ID, lookId);
484
485 } else {
486 component.setLookId(lookId.getExpressionString());
487 }
488 }
489
490 if (styleClass != null) {
491 if (styleClass.isLiteralText()==false) {
492 component.setValueExpression(Properties.STYLE_CLASS, styleClass);
493
494 } else {
495 component.setStyleClass(styleClass.getExpressionString());
496 }
497 }
498
499 if (width != null) {
500 if (width.isLiteralText()==false) {
501 component.setValueExpression(Properties.WIDTH, width);
502
503 } else {
504 component.setWidth(width.getExpressionString());
505 }
506 }
507
508 if (height != null) {
509 if (height.isLiteralText()==false) {
510 component.setValueExpression(Properties.HEIGHT, height);
511
512 } else {
513 component.setHeight(height.getExpressionString());
514 }
515 }
516
517 if (ariaLabel != null) {
518 if (ariaLabel.isLiteralText()==false) {
519 component.setValueExpression(Properties.ARIA_LABEL, ariaLabel);
520
521 } else {
522 component.setAriaLabel(ariaLabel.getExpressionString());
523 }
524 }
525
526 if (ariaLevel != null) {
527 if (ariaLevel.isLiteralText()==false) {
528 component.setValueExpression(Properties.ARIA_LEVEL, ariaLevel);
529
530 } else {
531 component.setAriaLevel(getInt(ariaLevel.getExpressionString()));
532 }
533 }
534
535 if (waiRole != null) {
536 if (waiRole.isLiteralText()==false) {
537 component.setValueExpression(Properties.WAI_ROLE, waiRole);
538
539 } else {
540 component.setWaiRole(waiRole.getExpressionString());
541 }
542 }
543
544 if (bottom != null) {
545 if (bottom.isLiteralText()==false) {
546 component.setValueExpression(Properties.BOTTOM, bottom);
547
548 } else {
549 component.setBottom(getInt(bottom.getExpressionString()));
550 }
551 }
552
553 if (left != null) {
554 if (left.isLiteralText()==false) {
555 component.setValueExpression(Properties.LEFT, left);
556
557 } else {
558 component.setLeft(getInt(left.getExpressionString()));
559 }
560 }
561
562 if (right != null) {
563 if (right.isLiteralText()==false) {
564 component.setValueExpression(Properties.RIGHT, right);
565
566 } else {
567 component.setRight(getInt(right.getExpressionString()));
568 }
569 }
570
571 if (top != null) {
572 if (top.isLiteralText()==false) {
573 component.setValueExpression(Properties.TOP, top);
574
575 } else {
576 component.setTop(getInt(top.getExpressionString()));
577 }
578 }
579
580 if (initListeners != null) {
581 ListenersTools1_2.parseListener(facesContext, component, ListenersTools.INIT_LISTENER_TYPE, initListeners);
582 }
583
584 if (hiddenMode != null) {
585 if (hiddenMode.isLiteralText()==false) {
586 component.setValueExpression(Properties.HIDDEN_MODE, hiddenMode);
587
588 } else {
589 component.setHiddenMode(hiddenMode.getExpressionString());
590 }
591 }
592
593 if (margins != null) {
594 if (margins.isLiteralText()==false) {
595 throw new javax.faces.FacesException("Attribute 'margins' does not accept binding !");
596 }
597 component.setMargins(margins.getExpressionString());
598 }
599
600 if (rows != null) {
601 if (rows.isLiteralText()==false) {
602 component.setValueExpression(Properties.ROWS, rows);
603
604 } else {
605 component.setRows(getInt(rows.getExpressionString()));
606 }
607 }
608
609 if (first != null) {
610 if (first.isLiteralText()==false) {
611 component.setValueExpression(Properties.FIRST, first);
612
613 } else {
614 component.setFirst(getInt(first.getExpressionString()));
615 }
616 }
617
618 if (var != null) {
619 if (var.isLiteralText()==false) {
620 component.setValueExpression(Properties.VAR, var);
621
622 } else {
623 component.setVar(var.getExpressionString());
624 }
625 }
626
627 if (value != null) {
628 if (value.isLiteralText()==false) {
629 component.setValueExpression(Properties.VALUE, value);
630
631 } else {
632 component.setValue(value.getExpressionString());
633 }
634 }
635 }
636
637 public void release() {
638 helpMessage = null;
639 helpURL = null;
640 toolTipText = null;
641 blurListeners = null;
642 focusListeners = null;
643 backgroundColor = null;
644 foregroundColor = null;
645 visible = null;
646 errorListeners = null;
647 sortManager = null;
648 mouseOutListeners = null;
649 mouseOverListeners = null;
650 tabIndex = null;
651 unlockedClientAttributeNames = null;
652 propertyChangeListeners = null;
653 marginBottom = null;
654 marginLeft = null;
655 marginRight = null;
656 marginTop = null;
657 keyUpListeners = null;
658 keyDownListeners = null;
659 keyPressListeners = null;
660 resetListeners = null;
661 userEventListeners = null;
662 x = null;
663 y = null;
664 partialRendering = null;
665 lookId = null;
666 styleClass = null;
667 width = null;
668 height = null;
669 ariaLabel = null;
670 ariaLevel = null;
671 waiRole = null;
672 bottom = null;
673 left = null;
674 right = null;
675 top = null;
676 initListeners = null;
677 hiddenMode = null;
678 margins = null;
679 rows = null;
680 first = null;
681 var = null;
682 value = null;
683
684 super.release();
685 }
686
687 }