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