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