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 org.rcfaces.core.component.TabComponent;
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 TabTag extends CardTag implements Tag {
17  
18  
19  	private static final Log LOG=LogFactory.getLog(TabTag.class);
20  
21  	private ValueExpression text;
22  	private ValueExpression textDirection;
23  	private ValueExpression fontBold;
24  	private ValueExpression fontItalic;
25  	private ValueExpression fontName;
26  	private ValueExpression fontSize;
27  	private ValueExpression fontUnderline;
28  	private ValueExpression disabled;
29  	private ValueExpression disabledImageURL;
30  	private ValueExpression hoverImageURL;
31  	private ValueExpression selectedImageURL;
32  	private ValueExpression imageURL;
33  	private ValueExpression accessKey;
34  	public String getComponentType() {
35  		return TabComponent.COMPONENT_TYPE;
36  	}
37  
38  	public final void setText(ValueExpression text) {
39  		this.text = text;
40  	}
41  
42  	public final void setTextDirection(ValueExpression textDirection) {
43  		this.textDirection = textDirection;
44  	}
45  
46  	public final void setFontBold(ValueExpression fontBold) {
47  		this.fontBold = fontBold;
48  	}
49  
50  	public final void setFontItalic(ValueExpression fontItalic) {
51  		this.fontItalic = fontItalic;
52  	}
53  
54  	public final void setFontName(ValueExpression fontName) {
55  		this.fontName = fontName;
56  	}
57  
58  	public final void setFontSize(ValueExpression fontSize) {
59  		this.fontSize = fontSize;
60  	}
61  
62  	public final void setFontUnderline(ValueExpression fontUnderline) {
63  		this.fontUnderline = fontUnderline;
64  	}
65  
66  	public final void setDisabled(ValueExpression disabled) {
67  		this.disabled = disabled;
68  	}
69  
70  	public final void setDisabledImageURL(ValueExpression disabledImageURL) {
71  		this.disabledImageURL = disabledImageURL;
72  	}
73  
74  	public final void setHoverImageURL(ValueExpression hoverImageURL) {
75  		this.hoverImageURL = hoverImageURL;
76  	}
77  
78  	public final void setSelectedImageURL(ValueExpression selectedImageURL) {
79  		this.selectedImageURL = selectedImageURL;
80  	}
81  
82  	public final void setImageURL(ValueExpression imageURL) {
83  		this.imageURL = imageURL;
84  	}
85  
86  	public final void setAccessKey(ValueExpression accessKey) {
87  		this.accessKey = accessKey;
88  	}
89  
90  	protected void setProperties(UIComponent uiComponent) {
91  		if (LOG.isDebugEnabled()) {
92  			if (TabComponent.COMPONENT_TYPE==getComponentType()) {
93  				LOG.debug("Component id='"+getId()+"' type='"+getComponentType()+"'.");
94  			}
95  			LOG.debug("  text='"+text+"'");
96  			LOG.debug("  textDirection='"+textDirection+"'");
97  			LOG.debug("  fontBold='"+fontBold+"'");
98  			LOG.debug("  fontItalic='"+fontItalic+"'");
99  			LOG.debug("  fontName='"+fontName+"'");
100 			LOG.debug("  fontSize='"+fontSize+"'");
101 			LOG.debug("  fontUnderline='"+fontUnderline+"'");
102 			LOG.debug("  disabled='"+disabled+"'");
103 			LOG.debug("  disabledImageURL='"+disabledImageURL+"'");
104 			LOG.debug("  hoverImageURL='"+hoverImageURL+"'");
105 			LOG.debug("  selectedImageURL='"+selectedImageURL+"'");
106 			LOG.debug("  imageURL='"+imageURL+"'");
107 			LOG.debug("  accessKey='"+accessKey+"'");
108 		}
109 		if ((uiComponent instanceof TabComponent)==false) {
110 			if (uiComponent instanceof UIViewRoot) {
111 				throw new IllegalStateException("The first component of the page must be a UIViewRoot component !");
112 			}
113 			throw new IllegalStateException("Component specified by tag is not instanceof of 'TabComponent'.");
114 		}
115 
116 		super.setProperties(uiComponent);
117 
118 		TabComponent component = (TabComponent) uiComponent;
119 		FacesContext facesContext = getFacesContext();
120 
121 		if (text != null) {
122 			if (text.isLiteralText()==false) {
123 				component.setValueExpression(Properties.TEXT, text);
124 
125 			} else {
126 				component.setText(text.getExpressionString());
127 			}
128 		}
129 
130 		if (textDirection != null) {
131 			if (textDirection.isLiteralText()==false) {
132 				component.setValueExpression(Properties.TEXT_DIRECTION, textDirection);
133 
134 			} else {
135 				component.setTextDirection(getInt(textDirection.getExpressionString()));
136 			}
137 		}
138 
139 		if (fontBold != null) {
140 			if (fontBold.isLiteralText()==false) {
141 				component.setValueExpression(Properties.FONT_BOLD, fontBold);
142 
143 			} else {
144 				component.setFontBold(getBoolean(fontBold.getExpressionString()));
145 			}
146 		}
147 
148 		if (fontItalic != null) {
149 			if (fontItalic.isLiteralText()==false) {
150 				component.setValueExpression(Properties.FONT_ITALIC, fontItalic);
151 
152 			} else {
153 				component.setFontItalic(getBoolean(fontItalic.getExpressionString()));
154 			}
155 		}
156 
157 		if (fontName != null) {
158 			if (fontName.isLiteralText()==false) {
159 				component.setValueExpression(Properties.FONT_NAME, fontName);
160 
161 			} else {
162 				component.setFontName(fontName.getExpressionString());
163 			}
164 		}
165 
166 		if (fontSize != null) {
167 			if (fontSize.isLiteralText()==false) {
168 				component.setValueExpression(Properties.FONT_SIZE, fontSize);
169 
170 			} else {
171 				component.setFontSize(fontSize.getExpressionString());
172 			}
173 		}
174 
175 		if (fontUnderline != null) {
176 			if (fontUnderline.isLiteralText()==false) {
177 				component.setValueExpression(Properties.FONT_UNDERLINE, fontUnderline);
178 
179 			} else {
180 				component.setFontUnderline(getBoolean(fontUnderline.getExpressionString()));
181 			}
182 		}
183 
184 		if (disabled != null) {
185 			if (disabled.isLiteralText()==false) {
186 				component.setValueExpression(Properties.DISABLED, disabled);
187 
188 			} else {
189 				component.setDisabled(getBool(disabled.getExpressionString()));
190 			}
191 		}
192 
193 		if (disabledImageURL != null) {
194 			if (disabledImageURL.isLiteralText()==false) {
195 				component.setValueExpression(Properties.DISABLED_IMAGE_URL, disabledImageURL);
196 
197 			} else {
198 				component.setDisabledImageURL(disabledImageURL.getExpressionString());
199 			}
200 		}
201 
202 		if (hoverImageURL != null) {
203 			if (hoverImageURL.isLiteralText()==false) {
204 				component.setValueExpression(Properties.HOVER_IMAGE_URL, hoverImageURL);
205 
206 			} else {
207 				component.setHoverImageURL(hoverImageURL.getExpressionString());
208 			}
209 		}
210 
211 		if (selectedImageURL != null) {
212 			if (selectedImageURL.isLiteralText()==false) {
213 				component.setValueExpression(Properties.SELECTED_IMAGE_URL, selectedImageURL);
214 
215 			} else {
216 				component.setSelectedImageURL(selectedImageURL.getExpressionString());
217 			}
218 		}
219 
220 		if (imageURL != null) {
221 			if (imageURL.isLiteralText()==false) {
222 				component.setValueExpression(Properties.IMAGE_URL, imageURL);
223 
224 			} else {
225 				component.setImageURL(imageURL.getExpressionString());
226 			}
227 		}
228 
229 		if (accessKey != null) {
230 			if (accessKey.isLiteralText()==false) {
231 				component.setValueExpression(Properties.ACCESS_KEY, accessKey);
232 
233 			} else {
234 				component.setAccessKey(accessKey.getExpressionString());
235 			}
236 		}
237 	}
238 
239 	public void release() {
240 		text = null;
241 		textDirection = null;
242 		fontBold = null;
243 		fontItalic = null;
244 		fontName = null;
245 		fontSize = null;
246 		fontUnderline = null;
247 		disabled = null;
248 		disabledImageURL = null;
249 		hoverImageURL = null;
250 		selectedImageURL = null;
251 		imageURL = null;
252 		accessKey = null;
253 
254 		super.release();
255 	}
256 
257 }