View Javadoc

1   package org.rcfaces.core.component;
2   
3   import org.rcfaces.core.internal.component.Properties;
4   import javax.el.ValueExpression;
5   import org.apache.commons.logging.Log;
6   import java.util.HashSet;
7   import org.rcfaces.core.component.AbstractMessagesComponent;
8   import org.apache.commons.logging.LogFactory;
9   import java.util.Arrays;
10  import java.util.Set;
11  import org.rcfaces.core.component.capability.ISeverityStyleClassCapability;
12  
13  /**
14   * <p>The messages Component is a placeholder for error messages (several messages can be shown simultaneously).</p>
15   * <p>The messages Component has the following capabilities :
16   * <ul>
17   * <li>ISeverityStyleClassCapability</li>
18   * </ul>
19   * </p>
20   * <p>The default <a href="/apidocs/index.html?org/rcfaces/core/component/MessagesComponent.html">messages</a> renderer is linked to the <a href="/jsdocs/index.html?f_messages.html" target="_blank">f_messages</a> javascript class. f_messages extends  f_component, fa_messageText</p>
21   * 
22   * <p> Table of component style classes: </p>
23   * <table border="1" cellpadding="3" cellspacing="0" width="100%">
24   * <tbody>
25   * 
26   * <tr style="text-align:left">
27   * <th  width="33%">Style Name</th>
28   * <th width="50%">Description</th>
29   * </tr>
30   * 
31   * <tr  style="text-align:left">
32   * <td width="33%">f_messages</td>
33   * <td width="50%">Defines styles for the wrapper  element</td>
34   * </tr>
35   * 
36   * </tbody>
37   * </table>
38   */
39  public class MessagesComponent extends AbstractMessagesComponent implements 
40  	ISeverityStyleClassCapability {
41  
42  	private static final Log LOG = LogFactory.getLog(MessagesComponent.class);
43  
44  	public static final String COMPONENT_TYPE="org.rcfaces.core.messages";
45  
46  	protected static final Set CAMELIA_ATTRIBUTES=new HashSet(AbstractMessagesComponent.CAMELIA_ATTRIBUTES);
47  	static {
48  		CAMELIA_ATTRIBUTES.addAll(Arrays.asList(new String[] {"fatalStyleClass","showIfMessage","warnStyleClass","errorStyleClass","infoStyleClass","styleClass","maxCount","showActiveComponentMessage"}));
49  	}
50  
51  	public MessagesComponent() {
52  		setRendererType(COMPONENT_TYPE);
53  	}
54  
55  	public MessagesComponent(String componentId) {
56  		this();
57  		setId(componentId);
58  	}
59  
60  	public java.lang.String getErrorStyleClass() {
61  		return getErrorStyleClass(null);
62  	}
63  
64  	/**
65  	 * See {@link #getErrorStyleClass() getErrorStyleClass()} for more details
66  	 */
67  	public java.lang.String getErrorStyleClass(javax.faces.context.FacesContext facesContext) {
68  		return engine.getStringProperty(Properties.ERROR_STYLE_CLASS, facesContext);
69  	}
70  
71  	/**
72  	 * Returns <code>true</code> if the attribute "errorStyleClass" is set.
73  	 * @return <code>true</code> if the attribute is set.
74  	 */
75  	public final boolean isErrorStyleClassSetted() {
76  		return engine.isPropertySetted(Properties.ERROR_STYLE_CLASS);
77  	}
78  
79  	public void setErrorStyleClass(java.lang.String errorStyleClass) {
80  		engine.setProperty(Properties.ERROR_STYLE_CLASS, errorStyleClass);
81  	}
82  
83  	public java.lang.String getFatalStyleClass() {
84  		return getFatalStyleClass(null);
85  	}
86  
87  	/**
88  	 * See {@link #getFatalStyleClass() getFatalStyleClass()} for more details
89  	 */
90  	public java.lang.String getFatalStyleClass(javax.faces.context.FacesContext facesContext) {
91  		return engine.getStringProperty(Properties.FATAL_STYLE_CLASS, facesContext);
92  	}
93  
94  	/**
95  	 * Returns <code>true</code> if the attribute "fatalStyleClass" is set.
96  	 * @return <code>true</code> if the attribute is set.
97  	 */
98  	public final boolean isFatalStyleClassSetted() {
99  		return engine.isPropertySetted(Properties.FATAL_STYLE_CLASS);
100 	}
101 
102 	public void setFatalStyleClass(java.lang.String fatalStyleClass) {
103 		engine.setProperty(Properties.FATAL_STYLE_CLASS, fatalStyleClass);
104 	}
105 
106 	public java.lang.String getInfoStyleClass() {
107 		return getInfoStyleClass(null);
108 	}
109 
110 	/**
111 	 * See {@link #getInfoStyleClass() getInfoStyleClass()} for more details
112 	 */
113 	public java.lang.String getInfoStyleClass(javax.faces.context.FacesContext facesContext) {
114 		return engine.getStringProperty(Properties.INFO_STYLE_CLASS, facesContext);
115 	}
116 
117 	/**
118 	 * Returns <code>true</code> if the attribute "infoStyleClass" is set.
119 	 * @return <code>true</code> if the attribute is set.
120 	 */
121 	public final boolean isInfoStyleClassSetted() {
122 		return engine.isPropertySetted(Properties.INFO_STYLE_CLASS);
123 	}
124 
125 	public void setInfoStyleClass(java.lang.String infoStyleClass) {
126 		engine.setProperty(Properties.INFO_STYLE_CLASS, infoStyleClass);
127 	}
128 
129 	public java.lang.String getWarnStyleClass() {
130 		return getWarnStyleClass(null);
131 	}
132 
133 	/**
134 	 * See {@link #getWarnStyleClass() getWarnStyleClass()} for more details
135 	 */
136 	public java.lang.String getWarnStyleClass(javax.faces.context.FacesContext facesContext) {
137 		return engine.getStringProperty(Properties.WARN_STYLE_CLASS, facesContext);
138 	}
139 
140 	/**
141 	 * Returns <code>true</code> if the attribute "warnStyleClass" is set.
142 	 * @return <code>true</code> if the attribute is set.
143 	 */
144 	public final boolean isWarnStyleClassSetted() {
145 		return engine.isPropertySetted(Properties.WARN_STYLE_CLASS);
146 	}
147 
148 	public void setWarnStyleClass(java.lang.String warnStyleClass) {
149 		engine.setProperty(Properties.WARN_STYLE_CLASS, warnStyleClass);
150 	}
151 
152 	public boolean isShowIfMessage() {
153 		return isShowIfMessage(null);
154 	}
155 
156 	public boolean isShowIfMessage(javax.faces.context.FacesContext facesContext) {
157 		return engine.getBoolProperty(Properties.SHOW_IF_MESSAGE, false, facesContext);
158 	}
159 
160 	public void setShowIfMessage(boolean showIfMessage) {
161 		engine.setProperty(Properties.SHOW_IF_MESSAGE, showIfMessage);
162 	}
163 
164 	/**
165 	 * Returns <code>true</code> if the attribute "showIfMessage" is set.
166 	 * @return <code>true</code> if the attribute is set.
167 	 */
168 	public boolean isShowIfMessageSetted() {
169 		return engine.isPropertySetted(Properties.SHOW_IF_MESSAGE);
170 	}
171 
172 	public boolean isShowActiveComponentMessage() {
173 		return isShowActiveComponentMessage(null);
174 	}
175 
176 	public boolean isShowActiveComponentMessage(javax.faces.context.FacesContext facesContext) {
177 		return engine.getBoolProperty(Properties.SHOW_ACTIVE_COMPONENT_MESSAGE, false, facesContext);
178 	}
179 
180 	public void setShowActiveComponentMessage(boolean showActiveComponentMessage) {
181 		engine.setProperty(Properties.SHOW_ACTIVE_COMPONENT_MESSAGE, showActiveComponentMessage);
182 	}
183 
184 	/**
185 	 * Returns <code>true</code> if the attribute "showActiveComponentMessage" is set.
186 	 * @return <code>true</code> if the attribute is set.
187 	 */
188 	public boolean isShowActiveComponentMessageSetted() {
189 		return engine.isPropertySetted(Properties.SHOW_ACTIVE_COMPONENT_MESSAGE);
190 	}
191 
192 	public int getMaxCount() {
193 		return getMaxCount(null);
194 	}
195 
196 	public int getMaxCount(javax.faces.context.FacesContext facesContext) {
197 		return engine.getIntProperty(Properties.MAX_COUNT, 0, facesContext);
198 	}
199 
200 	public void setMaxCount(int maxCount) {
201 		engine.setProperty(Properties.MAX_COUNT, maxCount);
202 	}
203 
204 	/**
205 	 * Returns <code>true</code> if the attribute "maxCount" is set.
206 	 * @return <code>true</code> if the attribute is set.
207 	 */
208 	public boolean isMaxCountSetted() {
209 		return engine.isPropertySetted(Properties.MAX_COUNT);
210 	}
211 
212 	protected Set getCameliaFields() {
213 		return CAMELIA_ATTRIBUTES;
214 	}
215 }