View Javadoc

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.AbstractMessagesComponent;
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 AbstractMessagesTag extends CameliaTag implements Tag {
17  
18  
19  	private static final Log LOG=LogFactory.getLog(AbstractMessagesTag.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 margins;
54  	private ValueExpression showSummary;
55  	private ValueExpression globalOnly;
56  	private ValueExpression showDetail;
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 setMargins(ValueExpression margins) {
186 		this.margins = margins;
187 	}
188 
189 	public final void setShowSummary(ValueExpression showSummary) {
190 		this.showSummary = showSummary;
191 	}
192 
193 	public final void setGlobalOnly(ValueExpression globalOnly) {
194 		this.globalOnly = globalOnly;
195 	}
196 
197 	public final void setShowDetail(ValueExpression showDetail) {
198 		this.showDetail = showDetail;
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("  margins='"+margins+"'");
230 			LOG.debug("  showSummary='"+showSummary+"'");
231 			LOG.debug("  globalOnly='"+globalOnly+"'");
232 			LOG.debug("  showDetail='"+showDetail+"'");
233 		}
234 		if ((uiComponent instanceof AbstractMessagesComponent)==false) {
235 			if (uiComponent instanceof UIViewRoot) {
236 				throw new IllegalStateException("The first component of the page must be a UIViewRoot component !");
237 			}
238 			throw new IllegalStateException("Component specified by tag is not instanceof of 'AbstractMessagesComponent'.");
239 		}
240 
241 		super.setProperties(uiComponent);
242 
243 		AbstractMessagesComponent component = (AbstractMessagesComponent) uiComponent;
244 		FacesContext facesContext = getFacesContext();
245 
246 		if (marginBottom != null) {
247 			if (marginBottom.isLiteralText()==false) {
248 				component.setValueExpression(Properties.MARGIN_BOTTOM, marginBottom);
249 
250 			} else {
251 				component.setMarginBottom(marginBottom.getExpressionString());
252 			}
253 		}
254 
255 		if (marginLeft != null) {
256 			if (marginLeft.isLiteralText()==false) {
257 				component.setValueExpression(Properties.MARGIN_LEFT, marginLeft);
258 
259 			} else {
260 				component.setMarginLeft(marginLeft.getExpressionString());
261 			}
262 		}
263 
264 		if (marginRight != null) {
265 			if (marginRight.isLiteralText()==false) {
266 				component.setValueExpression(Properties.MARGIN_RIGHT, marginRight);
267 
268 			} else {
269 				component.setMarginRight(marginRight.getExpressionString());
270 			}
271 		}
272 
273 		if (marginTop != null) {
274 			if (marginTop.isLiteralText()==false) {
275 				component.setValueExpression(Properties.MARGIN_TOP, marginTop);
276 
277 			} else {
278 				component.setMarginTop(marginTop.getExpressionString());
279 			}
280 		}
281 
282 		if (userEventListeners != null) {
283 			ListenersTools1_2.parseListener(facesContext, component, ListenersTools.USER_EVENT_LISTENER_TYPE, userEventListeners);
284 		}
285 
286 		if (x != null) {
287 			if (x.isLiteralText()==false) {
288 				component.setValueExpression(Properties.X, x);
289 
290 			} else {
291 				component.setX(x.getExpressionString());
292 			}
293 		}
294 
295 		if (y != null) {
296 			if (y.isLiteralText()==false) {
297 				component.setValueExpression(Properties.Y, y);
298 
299 			} else {
300 				component.setY(y.getExpressionString());
301 			}
302 		}
303 
304 		if (helpMessage != null) {
305 			if (helpMessage.isLiteralText()==false) {
306 				component.setValueExpression(Properties.HELP_MESSAGE, helpMessage);
307 
308 			} else {
309 				component.setHelpMessage(helpMessage.getExpressionString());
310 			}
311 		}
312 
313 		if (helpURL != null) {
314 			if (helpURL.isLiteralText()==false) {
315 				component.setValueExpression(Properties.HELP_URL, helpURL);
316 
317 			} else {
318 				component.setHelpURL(helpURL.getExpressionString());
319 			}
320 		}
321 
322 		if (toolTipText != null) {
323 			if (toolTipText.isLiteralText()==false) {
324 				component.setValueExpression(Properties.TOOL_TIP_TEXT, toolTipText);
325 
326 			} else {
327 				component.setToolTipText(toolTipText.getExpressionString());
328 			}
329 		}
330 
331 		if (partialRendering != null) {
332 			if (partialRendering.isLiteralText()==false) {
333 				component.setValueExpression(Properties.PARTIAL_RENDERING, partialRendering);
334 
335 			} else {
336 				component.setPartialRendering(getBool(partialRendering.getExpressionString()));
337 			}
338 		}
339 
340 		if (styleClass != null) {
341 			if (styleClass.isLiteralText()==false) {
342 				component.setValueExpression(Properties.STYLE_CLASS, styleClass);
343 
344 			} else {
345 				component.setStyleClass(styleClass.getExpressionString());
346 			}
347 		}
348 
349 		if (lookId != null) {
350 			if (lookId.isLiteralText()==false) {
351 				component.setValueExpression(Properties.LOOK_ID, lookId);
352 
353 			} else {
354 				component.setLookId(lookId.getExpressionString());
355 			}
356 		}
357 
358 		if (width != null) {
359 			if (width.isLiteralText()==false) {
360 				component.setValueExpression(Properties.WIDTH, width);
361 
362 			} else {
363 				component.setWidth(width.getExpressionString());
364 			}
365 		}
366 
367 		if (height != null) {
368 			if (height.isLiteralText()==false) {
369 				component.setValueExpression(Properties.HEIGHT, height);
370 
371 			} else {
372 				component.setHeight(height.getExpressionString());
373 			}
374 		}
375 
376 		if (backgroundColor != null) {
377 			if (backgroundColor.isLiteralText()==false) {
378 				component.setValueExpression(Properties.BACKGROUND_COLOR, backgroundColor);
379 
380 			} else {
381 				component.setBackgroundColor(backgroundColor.getExpressionString());
382 			}
383 		}
384 
385 		if (foregroundColor != null) {
386 			if (foregroundColor.isLiteralText()==false) {
387 				component.setValueExpression(Properties.FOREGROUND_COLOR, foregroundColor);
388 
389 			} else {
390 				component.setForegroundColor(foregroundColor.getExpressionString());
391 			}
392 		}
393 
394 		if (visible != null) {
395 			if (visible.isLiteralText()==false) {
396 				component.setValueExpression(Properties.VISIBLE, visible);
397 
398 			} else {
399 				component.setVisible(getBool(visible.getExpressionString()));
400 			}
401 		}
402 
403 		if (errorListeners != null) {
404 			ListenersTools1_2.parseListener(facesContext, component, ListenersTools.ERROR_LISTENER_TYPE, errorListeners);
405 		}
406 
407 		if (ariaLabel != null) {
408 			if (ariaLabel.isLiteralText()==false) {
409 				component.setValueExpression(Properties.ARIA_LABEL, ariaLabel);
410 
411 			} else {
412 				component.setAriaLabel(ariaLabel.getExpressionString());
413 			}
414 		}
415 
416 		if (ariaLevel != null) {
417 			if (ariaLevel.isLiteralText()==false) {
418 				component.setValueExpression(Properties.ARIA_LEVEL, ariaLevel);
419 
420 			} else {
421 				component.setAriaLevel(getInt(ariaLevel.getExpressionString()));
422 			}
423 		}
424 
425 		if (waiRole != null) {
426 			if (waiRole.isLiteralText()==false) {
427 				component.setValueExpression(Properties.WAI_ROLE, waiRole);
428 
429 			} else {
430 				component.setWaiRole(waiRole.getExpressionString());
431 			}
432 		}
433 
434 		if (bottom != null) {
435 			if (bottom.isLiteralText()==false) {
436 				component.setValueExpression(Properties.BOTTOM, bottom);
437 
438 			} else {
439 				component.setBottom(getInt(bottom.getExpressionString()));
440 			}
441 		}
442 
443 		if (left != null) {
444 			if (left.isLiteralText()==false) {
445 				component.setValueExpression(Properties.LEFT, left);
446 
447 			} else {
448 				component.setLeft(getInt(left.getExpressionString()));
449 			}
450 		}
451 
452 		if (right != null) {
453 			if (right.isLiteralText()==false) {
454 				component.setValueExpression(Properties.RIGHT, right);
455 
456 			} else {
457 				component.setRight(getInt(right.getExpressionString()));
458 			}
459 		}
460 
461 		if (top != null) {
462 			if (top.isLiteralText()==false) {
463 				component.setValueExpression(Properties.TOP, top);
464 
465 			} else {
466 				component.setTop(getInt(top.getExpressionString()));
467 			}
468 		}
469 
470 		if (mouseOutListeners != null) {
471 			ListenersTools1_2.parseListener(facesContext, component, ListenersTools.MOUSE_OUT_LISTENER_TYPE, mouseOutListeners);
472 		}
473 
474 		if (mouseOverListeners != null) {
475 			ListenersTools1_2.parseListener(facesContext, component, ListenersTools.MOUSE_OVER_LISTENER_TYPE, mouseOverListeners);
476 		}
477 
478 		if (unlockedClientAttributeNames != null) {
479 			if (unlockedClientAttributeNames.isLiteralText()==false) {
480 				component.setValueExpression(Properties.UNLOCKED_CLIENT_ATTRIBUTE_NAMES, unlockedClientAttributeNames);
481 
482 			} else {
483 				component.setUnlockedClientAttributeNames(unlockedClientAttributeNames.getExpressionString());
484 			}
485 		}
486 
487 		if (initListeners != null) {
488 			ListenersTools1_2.parseListener(facesContext, component, ListenersTools.INIT_LISTENER_TYPE, initListeners);
489 		}
490 
491 		if (propertyChangeListeners != null) {
492 			ListenersTools1_2.parseListener(facesContext, component, ListenersTools.PROPERTY_CHANGE_LISTENER_TYPE, propertyChangeListeners);
493 		}
494 
495 		if (hiddenMode != null) {
496 			if (hiddenMode.isLiteralText()==false) {
497 				component.setValueExpression(Properties.HIDDEN_MODE, hiddenMode);
498 
499 			} else {
500 				component.setHiddenMode(hiddenMode.getExpressionString());
501 			}
502 		}
503 
504 		if (margins != null) {
505 			if (margins.isLiteralText()==false) {
506 				throw new javax.faces.FacesException("Attribute 'margins' does not accept binding !");
507 			}
508 				component.setMargins(margins.getExpressionString());
509 		}
510 
511 		if (showSummary != null) {
512 			if (showSummary.isLiteralText()==false) {
513 				component.setValueExpression(Properties.SHOW_SUMMARY, showSummary);
514 
515 			} else {
516 				component.setShowSummary(getBool(showSummary.getExpressionString()));
517 			}
518 		}
519 
520 		if (globalOnly != null) {
521 			if (globalOnly.isLiteralText()==false) {
522 				component.setValueExpression(Properties.GLOBAL_ONLY, globalOnly);
523 
524 			} else {
525 				component.setGlobalOnly(getBool(globalOnly.getExpressionString()));
526 			}
527 		}
528 
529 		if (showDetail != null) {
530 			if (showDetail.isLiteralText()==false) {
531 				component.setValueExpression(Properties.SHOW_DETAIL, showDetail);
532 
533 			} else {
534 				component.setShowDetail(getBool(showDetail.getExpressionString()));
535 			}
536 		}
537 	}
538 
539 	public void release() {
540 		marginBottom = null;
541 		marginLeft = null;
542 		marginRight = null;
543 		marginTop = null;
544 		userEventListeners = null;
545 		x = null;
546 		y = null;
547 		helpMessage = null;
548 		helpURL = null;
549 		toolTipText = null;
550 		partialRendering = null;
551 		styleClass = null;
552 		lookId = null;
553 		width = null;
554 		height = null;
555 		backgroundColor = null;
556 		foregroundColor = null;
557 		visible = null;
558 		errorListeners = null;
559 		ariaLabel = null;
560 		ariaLevel = null;
561 		waiRole = null;
562 		bottom = null;
563 		left = null;
564 		right = null;
565 		top = null;
566 		mouseOutListeners = null;
567 		mouseOverListeners = null;
568 		unlockedClientAttributeNames = null;
569 		initListeners = null;
570 		propertyChangeListeners = null;
571 		hiddenMode = null;
572 		margins = null;
573 		showSummary = null;
574 		globalOnly = null;
575 		showDetail = null;
576 
577 		super.release();
578 	}
579 
580 }