View Javadoc

1   package org.rcfaces.core.component;
2   
3   import org.rcfaces.core.internal.component.Properties;
4   import org.rcfaces.core.component.familly.IContentAccessors;
5   import org.rcfaces.core.component.AbstractMessageComponent;
6   import org.apache.commons.logging.LogFactory;
7   import org.rcfaces.core.component.capability.IImageSizeCapability;
8   import javax.faces.context.FacesContext;
9   import org.rcfaces.core.component.capability.ISeverityImagesCapability;
10  import org.rcfaces.core.internal.tools.ImageAccessorTools;
11  import javax.el.ValueExpression;
12  import java.util.HashSet;
13  import org.apache.commons.logging.Log;
14  import java.util.Set;
15  import java.util.Arrays;
16  import org.rcfaces.core.internal.capability.IImageAccessorsCapability;
17  import org.rcfaces.core.component.capability.ITextCapability;
18  import org.rcfaces.core.component.capability.ISeverityStyleClassCapability;
19  
20  /**
21   * <p>The message Component is a placeholder for error messages (only one is shown).</p>
22   * <p>The message Component has the following capabilities :
23   * <ul>
24   * <li>IImageSizeCapability</li>
25   * <li>ITextCapability</li>
26   * <li>ISeverityStyleClassCapability</li>
27   * <li>ISeverityImagesCapability</li>
28   * <li>IImageAccessorsCapability</li>
29   * </ul>
30   * </p>
31   * 
32   * <p>The default <a href="/apidocs/index.html?org/rcfaces/core/component/MessageComponent.html">message</a> renderer is linked to the <a href="/jsdocs/index.html?f_message.html" target="_blank">f_message</a> javascript class. f_message extends f_component, fa_message1</p>
33   * 
34   * 
35   * <p> Table of component style classes: </p>
36   * <table border="1" cellpadding="3" cellspacing="0" width="100%">
37   * <tbody>
38   * 
39   * <tr style="text-align:left">
40   * <th  width="33%">Style Name</th>
41   * <th width="50%">Description</th>
42   * </tr>
43   * 
44   * <tr  style="text-align:left">
45   * <td width="33%">f_message</td>
46   * <td width="50%">Defines styles for the wrapper DIV element</td>
47   * </tr>
48   * 
49   * <tr  style="text-align:left">
50   * <td width="33%">f_message_summary</td>
51   * <td width="50%">Defines styles for the summary error message</td>
52   * </tr>
53   * 
54   * <tr  style="text-align:left">
55   * <td width="33%">f_message_detail</td>
56   * <td width="50%">Defines styles for the detail error message</td>
57   * </tr>
58   * 
59   * 
60   * </tbody>
61   * </table>
62   */
63  public class MessageComponent extends AbstractMessageComponent implements 
64  	IImageSizeCapability,
65  	ITextCapability,
66  	ISeverityStyleClassCapability,
67  	ISeverityImagesCapability,
68  	IImageAccessorsCapability {
69  
70  	private static final Log LOG = LogFactory.getLog(MessageComponent.class);
71  
72  	public static final String COMPONENT_TYPE="org.rcfaces.core.message";
73  
74  	protected static final Set CAMELIA_ATTRIBUTES=new HashSet(AbstractMessageComponent.CAMELIA_ATTRIBUTES);
75  	static {
76  		CAMELIA_ATTRIBUTES.addAll(Arrays.asList(new String[] {"imageHeight","text","fatalStyleClass","showIfMessage","styleClass","fatalImageURL","showActiveComponentMessage","errorStyleClass","warnStyleClass","infoStyleClass","infoImageURL","warnImageURL","errorImageURL","imageWidth","imageURL"}));
77  	}
78  
79  	public MessageComponent() {
80  		setRendererType(COMPONENT_TYPE);
81  	}
82  
83  	public MessageComponent(String componentId) {
84  		this();
85  		setId(componentId);
86  	}
87  
88  	public IContentAccessors getImageAccessors(FacesContext facesContext) {
89  
90  
91  			return ImageAccessorTools.createImageAccessors(facesContext, this, engine);
92  		
93  	}
94  
95  	public int getImageHeight() {
96  		return getImageHeight(null);
97  	}
98  
99  	/**
100 	 * See {@link #getImageHeight() getImageHeight()} for more details
101 	 */
102 	public int getImageHeight(javax.faces.context.FacesContext facesContext) {
103 		return engine.getIntProperty(Properties.IMAGE_HEIGHT,0, facesContext);
104 	}
105 
106 	/**
107 	 * Returns <code>true</code> if the attribute "imageHeight" is set.
108 	 * @return <code>true</code> if the attribute is set.
109 	 */
110 	public final boolean isImageHeightSetted() {
111 		return engine.isPropertySetted(Properties.IMAGE_HEIGHT);
112 	}
113 
114 	public void setImageHeight(int imageHeight) {
115 		engine.setProperty(Properties.IMAGE_HEIGHT, imageHeight);
116 	}
117 
118 	public int getImageWidth() {
119 		return getImageWidth(null);
120 	}
121 
122 	/**
123 	 * See {@link #getImageWidth() getImageWidth()} for more details
124 	 */
125 	public int getImageWidth(javax.faces.context.FacesContext facesContext) {
126 		return engine.getIntProperty(Properties.IMAGE_WIDTH,0, facesContext);
127 	}
128 
129 	/**
130 	 * Returns <code>true</code> if the attribute "imageWidth" is set.
131 	 * @return <code>true</code> if the attribute is set.
132 	 */
133 	public final boolean isImageWidthSetted() {
134 		return engine.isPropertySetted(Properties.IMAGE_WIDTH);
135 	}
136 
137 	public void setImageWidth(int imageWidth) {
138 		engine.setProperty(Properties.IMAGE_WIDTH, imageWidth);
139 	}
140 
141 	public java.lang.String getText() {
142 		return getText(null);
143 	}
144 
145 	/**
146 	 * See {@link #getText() getText()} for more details
147 	 */
148 	public java.lang.String getText(javax.faces.context.FacesContext facesContext) {
149 		return engine.getStringProperty(Properties.TEXT, facesContext);
150 	}
151 
152 	/**
153 	 * Returns <code>true</code> if the attribute "text" is set.
154 	 * @return <code>true</code> if the attribute is set.
155 	 */
156 	public final boolean isTextSetted() {
157 		return engine.isPropertySetted(Properties.TEXT);
158 	}
159 
160 	public void setText(java.lang.String text) {
161 		engine.setProperty(Properties.TEXT, text);
162 	}
163 
164 	public java.lang.String getErrorStyleClass() {
165 		return getErrorStyleClass(null);
166 	}
167 
168 	/**
169 	 * See {@link #getErrorStyleClass() getErrorStyleClass()} for more details
170 	 */
171 	public java.lang.String getErrorStyleClass(javax.faces.context.FacesContext facesContext) {
172 		return engine.getStringProperty(Properties.ERROR_STYLE_CLASS, facesContext);
173 	}
174 
175 	/**
176 	 * Returns <code>true</code> if the attribute "errorStyleClass" is set.
177 	 * @return <code>true</code> if the attribute is set.
178 	 */
179 	public final boolean isErrorStyleClassSetted() {
180 		return engine.isPropertySetted(Properties.ERROR_STYLE_CLASS);
181 	}
182 
183 	public void setErrorStyleClass(java.lang.String errorStyleClass) {
184 		engine.setProperty(Properties.ERROR_STYLE_CLASS, errorStyleClass);
185 	}
186 
187 	public java.lang.String getFatalStyleClass() {
188 		return getFatalStyleClass(null);
189 	}
190 
191 	/**
192 	 * See {@link #getFatalStyleClass() getFatalStyleClass()} for more details
193 	 */
194 	public java.lang.String getFatalStyleClass(javax.faces.context.FacesContext facesContext) {
195 		return engine.getStringProperty(Properties.FATAL_STYLE_CLASS, facesContext);
196 	}
197 
198 	/**
199 	 * Returns <code>true</code> if the attribute "fatalStyleClass" is set.
200 	 * @return <code>true</code> if the attribute is set.
201 	 */
202 	public final boolean isFatalStyleClassSetted() {
203 		return engine.isPropertySetted(Properties.FATAL_STYLE_CLASS);
204 	}
205 
206 	public void setFatalStyleClass(java.lang.String fatalStyleClass) {
207 		engine.setProperty(Properties.FATAL_STYLE_CLASS, fatalStyleClass);
208 	}
209 
210 	public java.lang.String getInfoStyleClass() {
211 		return getInfoStyleClass(null);
212 	}
213 
214 	/**
215 	 * See {@link #getInfoStyleClass() getInfoStyleClass()} for more details
216 	 */
217 	public java.lang.String getInfoStyleClass(javax.faces.context.FacesContext facesContext) {
218 		return engine.getStringProperty(Properties.INFO_STYLE_CLASS, facesContext);
219 	}
220 
221 	/**
222 	 * Returns <code>true</code> if the attribute "infoStyleClass" is set.
223 	 * @return <code>true</code> if the attribute is set.
224 	 */
225 	public final boolean isInfoStyleClassSetted() {
226 		return engine.isPropertySetted(Properties.INFO_STYLE_CLASS);
227 	}
228 
229 	public void setInfoStyleClass(java.lang.String infoStyleClass) {
230 		engine.setProperty(Properties.INFO_STYLE_CLASS, infoStyleClass);
231 	}
232 
233 	public java.lang.String getWarnStyleClass() {
234 		return getWarnStyleClass(null);
235 	}
236 
237 	/**
238 	 * See {@link #getWarnStyleClass() getWarnStyleClass()} for more details
239 	 */
240 	public java.lang.String getWarnStyleClass(javax.faces.context.FacesContext facesContext) {
241 		return engine.getStringProperty(Properties.WARN_STYLE_CLASS, facesContext);
242 	}
243 
244 	/**
245 	 * Returns <code>true</code> if the attribute "warnStyleClass" is set.
246 	 * @return <code>true</code> if the attribute is set.
247 	 */
248 	public final boolean isWarnStyleClassSetted() {
249 		return engine.isPropertySetted(Properties.WARN_STYLE_CLASS);
250 	}
251 
252 	public void setWarnStyleClass(java.lang.String warnStyleClass) {
253 		engine.setProperty(Properties.WARN_STYLE_CLASS, warnStyleClass);
254 	}
255 
256 	public java.lang.String getErrorImageURL() {
257 		return getErrorImageURL(null);
258 	}
259 
260 	/**
261 	 * See {@link #getErrorImageURL() getErrorImageURL()} for more details
262 	 */
263 	public java.lang.String getErrorImageURL(javax.faces.context.FacesContext facesContext) {
264 		return engine.getStringProperty(Properties.ERROR_IMAGE_URL, facesContext);
265 	}
266 
267 	/**
268 	 * Returns <code>true</code> if the attribute "errorImageURL" is set.
269 	 * @return <code>true</code> if the attribute is set.
270 	 */
271 	public final boolean isErrorImageURLSetted() {
272 		return engine.isPropertySetted(Properties.ERROR_IMAGE_URL);
273 	}
274 
275 	public void setErrorImageURL(java.lang.String errorImageURL) {
276 		engine.setProperty(Properties.ERROR_IMAGE_URL, errorImageURL);
277 	}
278 
279 	public java.lang.String getFatalImageURL() {
280 		return getFatalImageURL(null);
281 	}
282 
283 	/**
284 	 * See {@link #getFatalImageURL() getFatalImageURL()} for more details
285 	 */
286 	public java.lang.String getFatalImageURL(javax.faces.context.FacesContext facesContext) {
287 		return engine.getStringProperty(Properties.FATAL_IMAGE_URL, facesContext);
288 	}
289 
290 	/**
291 	 * Returns <code>true</code> if the attribute "fatalImageURL" is set.
292 	 * @return <code>true</code> if the attribute is set.
293 	 */
294 	public final boolean isFatalImageURLSetted() {
295 		return engine.isPropertySetted(Properties.FATAL_IMAGE_URL);
296 	}
297 
298 	public void setFatalImageURL(java.lang.String fatalImageURL) {
299 		engine.setProperty(Properties.FATAL_IMAGE_URL, fatalImageURL);
300 	}
301 
302 	public java.lang.String getInfoImageURL() {
303 		return getInfoImageURL(null);
304 	}
305 
306 	/**
307 	 * See {@link #getInfoImageURL() getInfoImageURL()} for more details
308 	 */
309 	public java.lang.String getInfoImageURL(javax.faces.context.FacesContext facesContext) {
310 		return engine.getStringProperty(Properties.INFO_IMAGE_URL, facesContext);
311 	}
312 
313 	/**
314 	 * Returns <code>true</code> if the attribute "infoImageURL" is set.
315 	 * @return <code>true</code> if the attribute is set.
316 	 */
317 	public final boolean isInfoImageURLSetted() {
318 		return engine.isPropertySetted(Properties.INFO_IMAGE_URL);
319 	}
320 
321 	public void setInfoImageURL(java.lang.String infoImageURL) {
322 		engine.setProperty(Properties.INFO_IMAGE_URL, infoImageURL);
323 	}
324 
325 	public java.lang.String getWarnImageURL() {
326 		return getWarnImageURL(null);
327 	}
328 
329 	/**
330 	 * See {@link #getWarnImageURL() getWarnImageURL()} for more details
331 	 */
332 	public java.lang.String getWarnImageURL(javax.faces.context.FacesContext facesContext) {
333 		return engine.getStringProperty(Properties.WARN_IMAGE_URL, facesContext);
334 	}
335 
336 	/**
337 	 * Returns <code>true</code> if the attribute "warnImageURL" is set.
338 	 * @return <code>true</code> if the attribute is set.
339 	 */
340 	public final boolean isWarnImageURLSetted() {
341 		return engine.isPropertySetted(Properties.WARN_IMAGE_URL);
342 	}
343 
344 	public void setWarnImageURL(java.lang.String warnImageURL) {
345 		engine.setProperty(Properties.WARN_IMAGE_URL, warnImageURL);
346 	}
347 
348 	public java.lang.String getImageURL() {
349 		return getImageURL(null);
350 	}
351 
352 	/**
353 	 * See {@link #getImageURL() getImageURL()} for more details
354 	 */
355 	public java.lang.String getImageURL(javax.faces.context.FacesContext facesContext) {
356 		return engine.getStringProperty(Properties.IMAGE_URL, facesContext);
357 	}
358 
359 	/**
360 	 * Returns <code>true</code> if the attribute "imageURL" is set.
361 	 * @return <code>true</code> if the attribute is set.
362 	 */
363 	public final boolean isImageURLSetted() {
364 		return engine.isPropertySetted(Properties.IMAGE_URL);
365 	}
366 
367 	public void setImageURL(java.lang.String imageURL) {
368 		engine.setProperty(Properties.IMAGE_URL, imageURL);
369 	}
370 
371 	public IContentAccessors getImageAccessors() {
372 
373 
374 			return getImageAccessors(null);
375 		
376 	}
377 
378 	public boolean isShowIfMessage() {
379 		return isShowIfMessage(null);
380 	}
381 
382 	public boolean isShowIfMessage(javax.faces.context.FacesContext facesContext) {
383 		return engine.getBoolProperty(Properties.SHOW_IF_MESSAGE, false, facesContext);
384 	}
385 
386 	public void setShowIfMessage(boolean showIfMessage) {
387 		engine.setProperty(Properties.SHOW_IF_MESSAGE, showIfMessage);
388 	}
389 
390 	/**
391 	 * Returns <code>true</code> if the attribute "showIfMessage" is set.
392 	 * @return <code>true</code> if the attribute is set.
393 	 */
394 	public boolean isShowIfMessageSetted() {
395 		return engine.isPropertySetted(Properties.SHOW_IF_MESSAGE);
396 	}
397 
398 	public boolean isShowActiveComponentMessage() {
399 		return isShowActiveComponentMessage(null);
400 	}
401 
402 	public boolean isShowActiveComponentMessage(javax.faces.context.FacesContext facesContext) {
403 		return engine.getBoolProperty(Properties.SHOW_ACTIVE_COMPONENT_MESSAGE, false, facesContext);
404 	}
405 
406 	public void setShowActiveComponentMessage(boolean showActiveComponentMessage) {
407 		engine.setProperty(Properties.SHOW_ACTIVE_COMPONENT_MESSAGE, showActiveComponentMessage);
408 	}
409 
410 	/**
411 	 * Returns <code>true</code> if the attribute "showActiveComponentMessage" is set.
412 	 * @return <code>true</code> if the attribute is set.
413 	 */
414 	public boolean isShowActiveComponentMessageSetted() {
415 		return engine.isPropertySetted(Properties.SHOW_ACTIVE_COMPONENT_MESSAGE);
416 	}
417 
418 	protected Set getCameliaFields() {
419 		return CAMELIA_ATTRIBUTES;
420 	}
421 }