View Javadoc

1   package org.rcfaces.core.component;
2   
3   import org.rcfaces.core.component.iterator.ICardIterator;
4   import org.rcfaces.core.component.capability.ISelectionEventCapability;
5   import org.rcfaces.core.internal.component.Properties;
6   import org.rcfaces.core.internal.tools.CardBoxTools;
7   import java.lang.String;
8   import org.apache.commons.logging.LogFactory;
9   import org.rcfaces.core.internal.converter.AsyncRenderModeConverter;
10  import javax.faces.context.FacesContext;
11  import javax.faces.event.PhaseId;
12  import org.rcfaces.core.component.capability.IAsyncRenderModeCapability;
13  import org.rcfaces.core.internal.capability.IPreferencesSettings;
14  import javax.el.ValueExpression;
15  import org.rcfaces.core.internal.converter.AsyncDecodeModeConverter;
16  import java.util.HashSet;
17  import org.apache.commons.logging.Log;
18  import org.rcfaces.core.component.CardComponent;
19  import java.util.Set;
20  import java.util.Arrays;
21  import org.rcfaces.core.internal.capability.IVariableScopeCapability;
22  import org.rcfaces.core.component.AbstractInputComponent;
23  import org.rcfaces.core.component.capability.IAsyncDecodeModeCapability;
24  
25  /**
26   * <p>The cardBox Component is similar to the <a href="/comps/tabbedPaneComponent.html">tabbedPane Component</a> without title and borders. It is usefull for showing alternatively different contents on the same page.</p>
27   * <p>The cardBox Component has the following capabilities :
28   * <ul>
29   * <li>ISelectionEventCapability</li>
30   * <li>IAsyncRenderModeCapability</li>
31   * <li>IPreferencesSettings</li>
32   * <li>IVariableScopeCapability</li>
33   * <li>IAsyncDecodeModeCapability</li>
34   * </ul>
35   * </p>
36   * 
37   * <p>The default <a href="/apidocs/index.html?org/rcfaces/core/component/CardBoxComponent.html">cardBox</a> renderer is linked to the <a href="/jsdocs/index.html?f_cardBox.html" target="_blank">f_cardBox</a> javascript class. f_cardBox extends f_component, fa_immediateu</p>
38   * 
39   * <p> Table of component style classes: </p>
40   * <table border="1" cellpadding="3" cellspacing="0" width="100%">
41   * <tbody>
42   * 
43   * <tr style="text-align:left">
44   * <th  width="33%">Style Name</th>
45   * <th width="50%">Description</th>
46   * </tr>
47   * 
48   * <tr  style="text-align:left">
49   * <td width="33%">f_cardBox</td>
50   * <td width="50%">Defines styles for the wrapper DIV element</td>
51   * </tr>
52   * 
53   * <tr  style="text-align:left">
54   * <td width="33%">f_cardBox_card</td>
55   * <td width="50%">Defines styles for the wrapper DIV element for each <a href="/apidocs/index.html?org/rcfaces/core/component/CardComponent.html">card</a></td>
56   * </tr>
57   * 
58   * </tbody>
59   * </table>
60   */
61  public class CardBoxComponent extends AbstractInputComponent implements 
62  	ISelectionEventCapability,
63  	IAsyncRenderModeCapability,
64  	IPreferencesSettings,
65  	IVariableScopeCapability,
66  	IAsyncDecodeModeCapability {
67  
68  	private static final Log LOG = LogFactory.getLog(CardBoxComponent.class);
69  
70  	public static final String COMPONENT_TYPE="org.rcfaces.core.cardBox";
71  
72  	protected static final Set CAMELIA_ATTRIBUTES=new HashSet(AbstractInputComponent.CAMELIA_ATTRIBUTES);
73  	static {
74  		CAMELIA_ATTRIBUTES.addAll(Arrays.asList(new String[] {"selectionListener","scopeSaveValue","scopeVar","scopeValue","asyncDecodeMode","asyncRenderMode","preferences"}));
75  	}
76  	protected static final String CAMELIA_VALUE_ALIAS="value";
77  
78  	public CardBoxComponent() {
79  		setRendererType(COMPONENT_TYPE);
80  	}
81  
82  	public CardBoxComponent(String componentId) {
83  		this();
84  		setId(componentId);
85  	}
86  
87  	public ICardIterator listCards() {
88  
89  
90  		return CardBoxTools.listCards(this);
91  		
92  	}
93  
94  	public CardComponent getSelectedCard() {
95  
96  
97  		return CardBoxTools.getSelectedCard(this);
98  		
99  	}
100 
101 	public CardComponent getSelectedCard(FacesContext facesContext) {
102 
103 
104 		return CardBoxTools.getSelectedCard(this);
105 		
106 	}
107 
108 	public void select(CardComponent card) {
109 
110 
111 			CardBoxTools.selectCard(this, card);
112 			
113 	}
114 
115 	public void setAsyncRenderMode(String asyncRenderMode) {
116 
117 
118 			setAsyncRenderMode(((Integer)AsyncRenderModeConverter.SINGLETON.getAsObject(null, this, asyncRenderMode)).intValue());
119 		
120 	}
121 
122 	public void setAsyncDecodeMode(String asyncDecodeMode) {
123 
124 
125 			setAsyncDecodeMode(((Integer)AsyncDecodeModeConverter.SINGLETON.getAsObject(null, this, asyncDecodeMode)).intValue());
126 		
127 	}
128 
129 	protected boolean verifyAsyncDecode(FacesContext facesContext, PhaseId phaseId) {
130 
131 
132 				return true;
133 			
134 	}
135 
136 	public final void addSelectionListener(org.rcfaces.core.event.ISelectionListener listener) {
137 		addFacesListener(listener);
138 	}
139 
140 	public final void removeSelectionListener(org.rcfaces.core.event.ISelectionListener listener) {
141 		removeFacesListener(listener);
142 	}
143 
144 	public final javax.faces.event.FacesListener [] listSelectionListeners() {
145 		return getFacesListeners(org.rcfaces.core.event.ISelectionListener.class);
146 	}
147 
148 	public int getAsyncRenderMode() {
149 		return getAsyncRenderMode(null);
150 	}
151 
152 	/**
153 	 * See {@link #getAsyncRenderMode() getAsyncRenderMode()} for more details
154 	 */
155 	public int getAsyncRenderMode(javax.faces.context.FacesContext facesContext) {
156 		return engine.getIntProperty(Properties.ASYNC_RENDER_MODE,0, facesContext);
157 	}
158 
159 	/**
160 	 * Returns <code>true</code> if the attribute "asyncRenderMode" is set.
161 	 * @return <code>true</code> if the attribute is set.
162 	 */
163 	public final boolean isAsyncRenderModeSetted() {
164 		return engine.isPropertySetted(Properties.ASYNC_RENDER_MODE);
165 	}
166 
167 	public void setAsyncRenderMode(int asyncRenderMode) {
168 		engine.setProperty(Properties.ASYNC_RENDER_MODE, asyncRenderMode);
169 	}
170 
171 	public org.rcfaces.core.preference.IComponentPreferences getPreferences() {
172 		return getPreferences(null);
173 	}
174 
175 	/**
176 	 * See {@link #getPreferences() getPreferences()} for more details
177 	 */
178 	public org.rcfaces.core.preference.IComponentPreferences getPreferences(javax.faces.context.FacesContext facesContext) {
179 		return (org.rcfaces.core.preference.IComponentPreferences)engine.getProperty(Properties.PREFERENCES, facesContext);
180 	}
181 
182 	/**
183 	 * Returns <code>true</code> if the attribute "preferences" is set.
184 	 * @return <code>true</code> if the attribute is set.
185 	 */
186 	public final boolean isPreferencesSetted() {
187 		return engine.isPropertySetted(Properties.PREFERENCES);
188 	}
189 
190 	public void setPreferences(org.rcfaces.core.preference.IComponentPreferences preferences) {
191 		engine.setProperty(Properties.PREFERENCES, preferences);
192 	}
193 
194 	public boolean isScopeSaveValue() {
195 		return isScopeSaveValue(null);
196 	}
197 
198 	/**
199 	 * See {@link #isScopeSaveValue() isScopeSaveValue()} for more details
200 	 */
201 	public boolean isScopeSaveValue(javax.faces.context.FacesContext facesContext) {
202 		return engine.getBoolProperty(Properties.SCOPE_SAVE_VALUE, false, facesContext);
203 	}
204 
205 	/**
206 	 * Returns <code>true</code> if the attribute "scopeSaveValue" is set.
207 	 * @return <code>true</code> if the attribute is set.
208 	 */
209 	public final boolean isScopeSaveValueSetted() {
210 		return engine.isPropertySetted(Properties.SCOPE_SAVE_VALUE);
211 	}
212 
213 	public void setScopeSaveValue(boolean scopeSaveValue) {
214 		engine.setProperty(Properties.SCOPE_SAVE_VALUE, scopeSaveValue);
215 	}
216 
217 	public java.lang.Object getScopeValue() {
218 		return getScopeValue(null);
219 	}
220 
221 	/**
222 	 * See {@link #getScopeValue() getScopeValue()} for more details
223 	 */
224 	public java.lang.Object getScopeValue(javax.faces.context.FacesContext facesContext) {
225 		return engine.getProperty(Properties.SCOPE_VALUE, facesContext);
226 	}
227 
228 	/**
229 	 * Returns <code>true</code> if the attribute "scopeValue" is set.
230 	 * @return <code>true</code> if the attribute is set.
231 	 */
232 	public final boolean isScopeValueSetted() {
233 		return engine.isPropertySetted(Properties.SCOPE_VALUE);
234 	}
235 
236 	public void setScopeValue(java.lang.Object scopeValue) {
237 		engine.setProperty(Properties.SCOPE_VALUE, scopeValue);
238 	}
239 
240 	public java.lang.String getScopeVar() {
241 		return getScopeVar(null);
242 	}
243 
244 	/**
245 	 * See {@link #getScopeVar() getScopeVar()} for more details
246 	 */
247 	public java.lang.String getScopeVar(javax.faces.context.FacesContext facesContext) {
248 		return engine.getStringProperty(Properties.SCOPE_VAR, facesContext);
249 	}
250 
251 	/**
252 	 * Returns <code>true</code> if the attribute "scopeVar" is set.
253 	 * @return <code>true</code> if the attribute is set.
254 	 */
255 	public final boolean isScopeVarSetted() {
256 		return engine.isPropertySetted(Properties.SCOPE_VAR);
257 	}
258 
259 	public void setScopeVar(java.lang.String scopeVar) {
260 		engine.setProperty(Properties.SCOPE_VAR, scopeVar);
261 	}
262 
263 	public int getAsyncDecodeMode() {
264 		return getAsyncDecodeMode(null);
265 	}
266 
267 	/**
268 	 * See {@link #getAsyncDecodeMode() getAsyncDecodeMode()} for more details
269 	 */
270 	public int getAsyncDecodeMode(javax.faces.context.FacesContext facesContext) {
271 		return engine.getIntProperty(Properties.ASYNC_DECODE_MODE,0, facesContext);
272 	}
273 
274 	/**
275 	 * Returns <code>true</code> if the attribute "asyncDecodeMode" is set.
276 	 * @return <code>true</code> if the attribute is set.
277 	 */
278 	public final boolean isAsyncDecodeModeSetted() {
279 		return engine.isPropertySetted(Properties.ASYNC_DECODE_MODE);
280 	}
281 
282 	public void setAsyncDecodeMode(int asyncDecodeMode) {
283 		engine.setProperty(Properties.ASYNC_DECODE_MODE, asyncDecodeMode);
284 	}
285 
286 	protected Set getCameliaFields() {
287 		return CAMELIA_ATTRIBUTES;
288 	}
289 
290 	protected String getCameliaValueAlias() {
291 		return CAMELIA_VALUE_ALIAS;
292 	}
293 }