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