View Javadoc

1   package org.rcfaces.core.internal.taglib;
2   
3   import org.rcfaces.core.component.BoxComponent;
4   import javax.faces.application.Application;
5   import javax.faces.component.UIComponent;
6   import org.rcfaces.core.internal.component.Properties;
7   import javax.el.ValueExpression;
8   import javax.faces.component.UIViewRoot;
9   import org.apache.commons.logging.Log;
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 class BoxTag extends AbstractBasicTag implements Tag {
17  
18  
19  	private static final Log LOG=LogFactory.getLog(BoxTag.class);
20  
21  	private ValueExpression backgroundImageHorizontalPosition;
22  	private ValueExpression backgroundImageHorizontalRepeat;
23  	private ValueExpression backgroundImageURL;
24  	private ValueExpression backgroundImageVerticalPosition;
25  	private ValueExpression backgroundImageVerticalRepeat;
26  	private ValueExpression border;
27  	private ValueExpression mouseOutListeners;
28  	private ValueExpression mouseOverListeners;
29  	private ValueExpression initListeners;
30  	private ValueExpression loadListeners;
31  	private ValueExpression layoutType;
32  	private ValueExpression asyncRenderMode;
33  	private ValueExpression asyncDecodeMode;
34  	private ValueExpression scopeSaveValue;
35  	private ValueExpression scopeValue;
36  	private ValueExpression scopeVar;
37  	private ValueExpression type;
38  	private ValueExpression overStyleClass;
39  	private ValueExpression horizontalScroll;
40  	private ValueExpression verticalScroll;
41  	public String getComponentType() {
42  		return BoxComponent.COMPONENT_TYPE;
43  	}
44  
45  	public final void setBackgroundImageHorizontalPosition(ValueExpression backgroundImageHorizontalPosition) {
46  		this.backgroundImageHorizontalPosition = backgroundImageHorizontalPosition;
47  	}
48  
49  	public final void setBackgroundImageHorizontalRepeat(ValueExpression backgroundImageHorizontalRepeat) {
50  		this.backgroundImageHorizontalRepeat = backgroundImageHorizontalRepeat;
51  	}
52  
53  	public final void setBackgroundImageURL(ValueExpression backgroundImageURL) {
54  		this.backgroundImageURL = backgroundImageURL;
55  	}
56  
57  	public final void setBackgroundImageVerticalPosition(ValueExpression backgroundImageVerticalPosition) {
58  		this.backgroundImageVerticalPosition = backgroundImageVerticalPosition;
59  	}
60  
61  	public final void setBackgroundImageVerticalRepeat(ValueExpression backgroundImageVerticalRepeat) {
62  		this.backgroundImageVerticalRepeat = backgroundImageVerticalRepeat;
63  	}
64  
65  	public final void setBorder(ValueExpression border) {
66  		this.border = border;
67  	}
68  
69  	public final void setMouseOutListener(ValueExpression mouseOutListeners) {
70  		this.mouseOutListeners = mouseOutListeners;
71  	}
72  
73  	public final void setMouseOverListener(ValueExpression mouseOverListeners) {
74  		this.mouseOverListeners = mouseOverListeners;
75  	}
76  
77  	public final void setInitListener(ValueExpression initListeners) {
78  		this.initListeners = initListeners;
79  	}
80  
81  	public final void setLoadListener(ValueExpression loadListeners) {
82  		this.loadListeners = loadListeners;
83  	}
84  
85  	public final void setLayoutType(ValueExpression layoutType) {
86  		this.layoutType = layoutType;
87  	}
88  
89  	public final void setAsyncRenderMode(ValueExpression asyncRenderMode) {
90  		this.asyncRenderMode = asyncRenderMode;
91  	}
92  
93  	public final void setAsyncDecodeMode(ValueExpression asyncDecodeMode) {
94  		this.asyncDecodeMode = asyncDecodeMode;
95  	}
96  
97  	public final void setScopeSaveValue(ValueExpression scopeSaveValue) {
98  		this.scopeSaveValue = scopeSaveValue;
99  	}
100 
101 	public final void setScopeValue(ValueExpression scopeValue) {
102 		this.scopeValue = scopeValue;
103 	}
104 
105 	public final void setScopeVar(ValueExpression scopeVar) {
106 		this.scopeVar = scopeVar;
107 	}
108 
109 	public final void setType(ValueExpression type) {
110 		this.type = type;
111 	}
112 
113 	public final void setOverStyleClass(ValueExpression overStyleClass) {
114 		this.overStyleClass = overStyleClass;
115 	}
116 
117 	public final void setHorizontalScroll(ValueExpression horizontalScroll) {
118 		this.horizontalScroll = horizontalScroll;
119 	}
120 
121 	public final void setVerticalScroll(ValueExpression verticalScroll) {
122 		this.verticalScroll = verticalScroll;
123 	}
124 
125 	protected void setProperties(UIComponent uiComponent) {
126 		if (LOG.isDebugEnabled()) {
127 			if (BoxComponent.COMPONENT_TYPE==getComponentType()) {
128 				LOG.debug("Component id='"+getId()+"' type='"+getComponentType()+"'.");
129 			}
130 			LOG.debug("  backgroundImageHorizontalPosition='"+backgroundImageHorizontalPosition+"'");
131 			LOG.debug("  backgroundImageHorizontalRepeat='"+backgroundImageHorizontalRepeat+"'");
132 			LOG.debug("  backgroundImageURL='"+backgroundImageURL+"'");
133 			LOG.debug("  backgroundImageVerticalPosition='"+backgroundImageVerticalPosition+"'");
134 			LOG.debug("  backgroundImageVerticalRepeat='"+backgroundImageVerticalRepeat+"'");
135 			LOG.debug("  border='"+border+"'");
136 			LOG.debug("  layoutType='"+layoutType+"'");
137 			LOG.debug("  asyncRenderMode='"+asyncRenderMode+"'");
138 			LOG.debug("  asyncDecodeMode='"+asyncDecodeMode+"'");
139 			LOG.debug("  scopeSaveValue='"+scopeSaveValue+"'");
140 			LOG.debug("  scopeValue='"+scopeValue+"'");
141 			LOG.debug("  scopeVar='"+scopeVar+"'");
142 			LOG.debug("  type='"+type+"'");
143 			LOG.debug("  overStyleClass='"+overStyleClass+"'");
144 			LOG.debug("  horizontalScroll='"+horizontalScroll+"'");
145 			LOG.debug("  verticalScroll='"+verticalScroll+"'");
146 		}
147 		if ((uiComponent instanceof BoxComponent)==false) {
148 			if (uiComponent instanceof UIViewRoot) {
149 				throw new IllegalStateException("The first component of the page must be a UIViewRoot component !");
150 			}
151 			throw new IllegalStateException("Component specified by tag is not instanceof of 'BoxComponent'.");
152 		}
153 
154 		super.setProperties(uiComponent);
155 
156 		BoxComponent component = (BoxComponent) uiComponent;
157 		FacesContext facesContext = getFacesContext();
158 
159 		if (backgroundImageHorizontalPosition != null) {
160 			if (backgroundImageHorizontalPosition.isLiteralText()==false) {
161 				component.setValueExpression(Properties.BACKGROUND_IMAGE_HORIZONTAL_POSITION, backgroundImageHorizontalPosition);
162 
163 			} else {
164 				component.setBackgroundImageHorizontalPosition(backgroundImageHorizontalPosition.getExpressionString());
165 			}
166 		}
167 
168 		if (backgroundImageHorizontalRepeat != null) {
169 			if (backgroundImageHorizontalRepeat.isLiteralText()==false) {
170 				component.setValueExpression(Properties.BACKGROUND_IMAGE_HORIZONTAL_REPEAT, backgroundImageHorizontalRepeat);
171 
172 			} else {
173 				component.setBackgroundImageHorizontalRepeat(getBool(backgroundImageHorizontalRepeat.getExpressionString()));
174 			}
175 		}
176 
177 		if (backgroundImageURL != null) {
178 			if (backgroundImageURL.isLiteralText()==false) {
179 				component.setValueExpression(Properties.BACKGROUND_IMAGE_URL, backgroundImageURL);
180 
181 			} else {
182 				component.setBackgroundImageURL(backgroundImageURL.getExpressionString());
183 			}
184 		}
185 
186 		if (backgroundImageVerticalPosition != null) {
187 			if (backgroundImageVerticalPosition.isLiteralText()==false) {
188 				component.setValueExpression(Properties.BACKGROUND_IMAGE_VERTICAL_POSITION, backgroundImageVerticalPosition);
189 
190 			} else {
191 				component.setBackgroundImageVerticalPosition(backgroundImageVerticalPosition.getExpressionString());
192 			}
193 		}
194 
195 		if (backgroundImageVerticalRepeat != null) {
196 			if (backgroundImageVerticalRepeat.isLiteralText()==false) {
197 				component.setValueExpression(Properties.BACKGROUND_IMAGE_VERTICAL_REPEAT, backgroundImageVerticalRepeat);
198 
199 			} else {
200 				component.setBackgroundImageVerticalRepeat(getBool(backgroundImageVerticalRepeat.getExpressionString()));
201 			}
202 		}
203 
204 		if (border != null) {
205 			if (border.isLiteralText()==false) {
206 				component.setValueExpression(Properties.BORDER, border);
207 
208 			} else {
209 				component.setBorder(getBool(border.getExpressionString()));
210 			}
211 		}
212 
213 		if (mouseOutListeners != null) {
214 			ListenersTools1_2.parseListener(facesContext, component, ListenersTools.MOUSE_OUT_LISTENER_TYPE, mouseOutListeners);
215 		}
216 
217 		if (mouseOverListeners != null) {
218 			ListenersTools1_2.parseListener(facesContext, component, ListenersTools.MOUSE_OVER_LISTENER_TYPE, mouseOverListeners);
219 		}
220 
221 		if (initListeners != null) {
222 			ListenersTools1_2.parseListener(facesContext, component, ListenersTools.INIT_LISTENER_TYPE, initListeners);
223 		}
224 
225 		if (loadListeners != null) {
226 			ListenersTools1_2.parseListener(facesContext, component, ListenersTools.LOAD_LISTENER_TYPE, loadListeners);
227 		}
228 
229 		if (layoutType != null) {
230 			if (layoutType.isLiteralText()==false) {
231 				component.setValueExpression(Properties.LAYOUT_TYPE, layoutType);
232 
233 			} else {
234 				component.setLayoutType(layoutType.getExpressionString());
235 			}
236 		}
237 
238 		if (asyncRenderMode != null) {
239 			if (asyncRenderMode.isLiteralText()==false) {
240 				component.setValueExpression(Properties.ASYNC_RENDER_MODE, asyncRenderMode);
241 
242 			} else {
243 				component.setAsyncRenderMode(asyncRenderMode.getExpressionString());
244 			}
245 		}
246 
247 		if (asyncDecodeMode != null) {
248 			if (asyncDecodeMode.isLiteralText()==false) {
249 				component.setValueExpression(Properties.ASYNC_DECODE_MODE, asyncDecodeMode);
250 
251 			} else {
252 				component.setAsyncDecodeMode(asyncDecodeMode.getExpressionString());
253 			}
254 		}
255 
256 		if (scopeSaveValue != null) {
257 			if (scopeSaveValue.isLiteralText()==false) {
258 				component.setValueExpression(Properties.SCOPE_SAVE_VALUE, scopeSaveValue);
259 
260 			} else {
261 				component.setScopeSaveValue(getBool(scopeSaveValue.getExpressionString()));
262 			}
263 		}
264 
265 		if (scopeValue != null) {
266 			if (scopeValue.isLiteralText()==false) {
267 				component.setValueExpression(Properties.SCOPE_VALUE, scopeValue);
268 
269 			} else {
270 				component.setScopeValue(scopeValue.getExpressionString());
271 			}
272 		}
273 
274 		if (scopeVar != null) {
275 			if (scopeVar.isLiteralText()==false) {
276 				component.setValueExpression(Properties.SCOPE_VAR, scopeVar);
277 
278 			} else {
279 				component.setScopeVar(scopeVar.getExpressionString());
280 			}
281 		}
282 
283 		if (type != null) {
284 			if (type.isLiteralText()==false) {
285 				component.setValueExpression(Properties.TYPE, type);
286 
287 			} else {
288 				component.setType(type.getExpressionString());
289 			}
290 		}
291 
292 		if (overStyleClass != null) {
293 			if (overStyleClass.isLiteralText()==false) {
294 				component.setValueExpression(Properties.OVER_STYLE_CLASS, overStyleClass);
295 
296 			} else {
297 				component.setOverStyleClass(overStyleClass.getExpressionString());
298 			}
299 		}
300 
301 		if (horizontalScroll != null) {
302 			if (horizontalScroll.isLiteralText()==false) {
303 				component.setValueExpression(Properties.HORIZONTAL_SCROLL, horizontalScroll);
304 
305 			} else {
306 				component.setHorizontalScroll(getBool(horizontalScroll.getExpressionString()));
307 			}
308 		}
309 
310 		if (verticalScroll != null) {
311 			if (verticalScroll.isLiteralText()==false) {
312 				component.setValueExpression(Properties.VERTICAL_SCROLL, verticalScroll);
313 
314 			} else {
315 				component.setVerticalScroll(getBool(verticalScroll.getExpressionString()));
316 			}
317 		}
318 	}
319 
320 	public void release() {
321 		backgroundImageHorizontalPosition = null;
322 		backgroundImageHorizontalRepeat = null;
323 		backgroundImageURL = null;
324 		backgroundImageVerticalPosition = null;
325 		backgroundImageVerticalRepeat = null;
326 		border = null;
327 		mouseOutListeners = null;
328 		mouseOverListeners = null;
329 		initListeners = null;
330 		loadListeners = null;
331 		layoutType = null;
332 		asyncRenderMode = null;
333 		asyncDecodeMode = null;
334 		scopeSaveValue = null;
335 		scopeValue = null;
336 		scopeVar = null;
337 		type = null;
338 		overStyleClass = null;
339 		horizontalScroll = null;
340 		verticalScroll = null;
341 
342 		super.release();
343 	}
344 
345 }