View Javadoc

1   package org.rcfaces.core.component;
2   
3   import org.rcfaces.core.internal.component.Properties;
4   import org.rcfaces.core.component.capability.ISuggestionEventCapability;
5   import java.lang.String;
6   import org.apache.commons.logging.LogFactory;
7   import javax.faces.context.FacesContext;
8   import org.rcfaces.core.component.TextEntryComponent;
9   import org.rcfaces.core.component.capability.IMaxResultNumberCapability;
10  import javax.faces.convert.Converter;
11  import org.rcfaces.core.internal.converter.FilterPropertiesConverter;
12  import javax.el.ValueExpression;
13  import java.util.HashSet;
14  import org.apache.commons.logging.Log;
15  import org.rcfaces.core.component.capability.IFilterCapability;
16  import org.rcfaces.core.model.IFilterProperties;
17  import java.util.Set;
18  import java.util.Arrays;
19  import org.rcfaces.core.component.capability.IMenuEventCapability;
20  import org.rcfaces.core.internal.tools.ComponentTools;
21  
22  /**
23   * <p>The suggestTextEntry is a <a href="/comps/textEntryCOmponent.html">textEntry Component</a> with an autosuggestion feature that shows in the form of a dropdown list.</p>
24   * <p>The suggestTextEntry Component has the following capabilities :
25   * <ul>
26   * <li>IFilterCapability</li>
27   * <li>IMaxResultNumberCapability</li>
28   * <li>ISuggestionEventCapability</li>
29   * <li>IMenuEventCapability</li>
30   * </ul>
31   * </p>
32   * 
33   * <p>The default <a href="/apidocs/index.html?org/rcfaces/core/component/SuggestTextEntryComponent.html">lineBreak</a> renderer is linked to the <a href="/jsdocs/index.html?f_suggestTextEntry.html" target="_blank">f_suggestTextEntry</a> javascript class. f_suggestTextEntry extends f_textEntry, fa_filterProperties, fa_commands</p>
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_suggestTextEntry</td>
46   * <td width="50%">Defines styles for the wrapper element</td>
47   * </tr>
48   * 
49   * </tbody>
50   * </table>
51   */
52  public class SuggestTextEntryComponent extends TextEntryComponent implements 
53  	IFilterCapability,
54  	IMaxResultNumberCapability,
55  	ISuggestionEventCapability,
56  	IMenuEventCapability {
57  
58  	private static final Log LOG = LogFactory.getLog(SuggestTextEntryComponent.class);
59  
60  	public static final String COMPONENT_TYPE="org.rcfaces.core.suggestTextEntry";
61  
62  	protected static final Set CAMELIA_ATTRIBUTES=new HashSet(TextEntryComponent.CAMELIA_ATTRIBUTES);
63  	static {
64  		CAMELIA_ATTRIBUTES.addAll(Arrays.asList(new String[] {"filterProperties","suggestionListener","suggestionConverter","suggestionMinChars","menuListener","maxResultNumber","orderedItems","caseSensitive","suggestionDelayMs","suggestionValue","forceProposal","moreResultsMessage"}));
65  	}
66  
67  	public SuggestTextEntryComponent() {
68  		setRendererType(COMPONENT_TYPE);
69  	}
70  
71  	public SuggestTextEntryComponent(String componentId) {
72  		this();
73  		setId(componentId);
74  	}
75  
76  	public void setSuggestionConverter(String converterId) {
77  
78  			
79  			setSuggestionConverter(converterId, null);
80  		
81  	}
82  
83  	public void setSuggestionConverter(String converterId, FacesContext facesContext) {
84  
85  
86  			Converter converter=ComponentTools.createConverter(facesContext, converterId);
87  
88  			setSuggestionConverter(converter);
89  		
90  	}
91  
92  	public void setFilterProperties(String properties) {
93  
94  
95  			IFilterProperties filterProperties=(IFilterProperties)FilterPropertiesConverter.SINGLETON.getAsObject(null, this, properties);
96  			
97  			setFilterProperties(filterProperties);
98  		
99  	}
100 
101 	public org.rcfaces.core.model.IFilterProperties getFilterProperties() {
102 		return getFilterProperties(null);
103 	}
104 
105 	/**
106 	 * See {@link #getFilterProperties() getFilterProperties()} for more details
107 	 */
108 	public org.rcfaces.core.model.IFilterProperties getFilterProperties(javax.faces.context.FacesContext facesContext) {
109 		return (org.rcfaces.core.model.IFilterProperties)engine.getProperty(Properties.FILTER_PROPERTIES, facesContext);
110 	}
111 
112 	/**
113 	 * Returns <code>true</code> if the attribute "filterProperties" is set.
114 	 * @return <code>true</code> if the attribute is set.
115 	 */
116 	public final boolean isFilterPropertiesSetted() {
117 		return engine.isPropertySetted(Properties.FILTER_PROPERTIES);
118 	}
119 
120 	public void setFilterProperties(org.rcfaces.core.model.IFilterProperties filterProperties) {
121 		engine.setProperty(Properties.FILTER_PROPERTIES, filterProperties);
122 	}
123 
124 	public int getMaxResultNumber() {
125 		return getMaxResultNumber(null);
126 	}
127 
128 	/**
129 	 * See {@link #getMaxResultNumber() getMaxResultNumber()} for more details
130 	 */
131 	public int getMaxResultNumber(javax.faces.context.FacesContext facesContext) {
132 		return engine.getIntProperty(Properties.MAX_RESULT_NUMBER,0, facesContext);
133 	}
134 
135 	/**
136 	 * Returns <code>true</code> if the attribute "maxResultNumber" is set.
137 	 * @return <code>true</code> if the attribute is set.
138 	 */
139 	public final boolean isMaxResultNumberSetted() {
140 		return engine.isPropertySetted(Properties.MAX_RESULT_NUMBER);
141 	}
142 
143 	public void setMaxResultNumber(int maxResultNumber) {
144 		engine.setProperty(Properties.MAX_RESULT_NUMBER, maxResultNumber);
145 	}
146 
147 	public final void addSuggestionListener(org.rcfaces.core.event.ISuggestionListener listener) {
148 		addFacesListener(listener);
149 	}
150 
151 	public final void removeSuggestionListener(org.rcfaces.core.event.ISuggestionListener listener) {
152 		removeFacesListener(listener);
153 	}
154 
155 	public final javax.faces.event.FacesListener [] listSuggestionListeners() {
156 		return getFacesListeners(org.rcfaces.core.event.ISuggestionListener.class);
157 	}
158 
159 	public final void addMenuListener(org.rcfaces.core.event.IMenuListener listener) {
160 		addFacesListener(listener);
161 	}
162 
163 	public final void removeMenuListener(org.rcfaces.core.event.IMenuListener listener) {
164 		removeFacesListener(listener);
165 	}
166 
167 	public final javax.faces.event.FacesListener [] listMenuListeners() {
168 		return getFacesListeners(org.rcfaces.core.event.IMenuListener.class);
169 	}
170 
171 	/**
172 	 * Returns an int value specifying the delay in milliseconds before showing the suggestion list.
173 	 * @return delay in milliseconds
174 	 */
175 	public int getSuggestionDelayMs() {
176 		return getSuggestionDelayMs(null);
177 	}
178 
179 	/**
180 	 * Returns an int value specifying the delay in milliseconds before showing the suggestion list.
181 	 * @return delay in milliseconds
182 	 */
183 	public int getSuggestionDelayMs(javax.faces.context.FacesContext facesContext) {
184 		return engine.getIntProperty(Properties.SUGGESTION_DELAY_MS, 0, facesContext);
185 	}
186 
187 	/**
188 	 * Sets an int value specifying the delay in milliseconds before showing the suggestion list.
189 	 * @param suggestionDelayMs delay in milliseconds
190 	 */
191 	public void setSuggestionDelayMs(int suggestionDelayMs) {
192 		engine.setProperty(Properties.SUGGESTION_DELAY_MS, suggestionDelayMs);
193 	}
194 
195 	/**
196 	 * Sets an int value specifying the delay in milliseconds before showing the suggestion list.
197 	 * @param suggestionDelayMs delay in milliseconds
198 	 */
199 	/**
200 	 * Returns <code>true</code> if the attribute "suggestionDelayMs" is set.
201 	 * @return <code>true</code> if the attribute is set.
202 	 */
203 	public boolean isSuggestionDelayMsSetted() {
204 		return engine.isPropertySetted(Properties.SUGGESTION_DELAY_MS);
205 	}
206 
207 	/**
208 	 * Returns an int value specifying the minimum number of characters before the suggestion is calculated.
209 	 * @return minimum number of characters
210 	 */
211 	public int getSuggestionMinChars() {
212 		return getSuggestionMinChars(null);
213 	}
214 
215 	/**
216 	 * Returns an int value specifying the minimum number of characters before the suggestion is calculated.
217 	 * @return minimum number of characters
218 	 */
219 	public int getSuggestionMinChars(javax.faces.context.FacesContext facesContext) {
220 		return engine.getIntProperty(Properties.SUGGESTION_MIN_CHARS, 0, facesContext);
221 	}
222 
223 	/**
224 	 * Sets an int value specifying the minimum number of characters before the suggestion is calculated.
225 	 * @param suggestionMinChars minimum number of characters
226 	 */
227 	public void setSuggestionMinChars(int suggestionMinChars) {
228 		engine.setProperty(Properties.SUGGESTION_MIN_CHARS, suggestionMinChars);
229 	}
230 
231 	/**
232 	 * Sets an int value specifying the minimum number of characters before the suggestion is calculated.
233 	 * @param suggestionMinChars minimum number of characters
234 	 */
235 	/**
236 	 * Returns <code>true</code> if the attribute "suggestionMinChars" is set.
237 	 * @return <code>true</code> if the attribute is set.
238 	 */
239 	public boolean isSuggestionMinCharsSetted() {
240 		return engine.isPropertySetted(Properties.SUGGESTION_MIN_CHARS);
241 	}
242 
243 	/**
244 	 * Returns a boolean value indicating if the component should consider the case of the user input when using the data.
245 	 * @return true if case sensitive
246 	 */
247 	public boolean isCaseSensitive() {
248 		return isCaseSensitive(null);
249 	}
250 
251 	/**
252 	 * Returns a boolean value indicating if the component should consider the case of the user input when using the data.
253 	 * @return true if case sensitive
254 	 */
255 	public boolean isCaseSensitive(javax.faces.context.FacesContext facesContext) {
256 		return engine.getBoolProperty(Properties.CASE_SENSITIVE, false, facesContext);
257 	}
258 
259 	/**
260 	 * Sets a boolean value indicating if the component should consider the case of the user input when using the data.
261 	 * @param caseSensitive <code>true</code> if case sensitive
262 	 */
263 	public void setCaseSensitive(boolean caseSensitive) {
264 		engine.setProperty(Properties.CASE_SENSITIVE, caseSensitive);
265 	}
266 
267 	/**
268 	 * Sets a boolean value indicating if the component should consider the case of the user input when using the data.
269 	 * @param caseSensitive <code>true</code> if case sensitive
270 	 */
271 	/**
272 	 * Returns <code>true</code> if the attribute "caseSensitive" is set.
273 	 * @return <code>true</code> if the attribute is set.
274 	 */
275 	public boolean isCaseSensitiveSetted() {
276 		return engine.isPropertySetted(Properties.CASE_SENSITIVE);
277 	}
278 
279 	/**
280 	 * Returns a boolean value indicating if the first proposed value must be automatically appended to the current entry.
281 	 * @return true if proposal is forced
282 	 */
283 	public boolean isForceProposal() {
284 		return isForceProposal(null);
285 	}
286 
287 	/**
288 	 * Returns a boolean value indicating if the first proposed value must be automatically appended to the current entry.
289 	 * @return true if proposal is forced
290 	 */
291 	public boolean isForceProposal(javax.faces.context.FacesContext facesContext) {
292 		return engine.getBoolProperty(Properties.FORCE_PROPOSAL, false, facesContext);
293 	}
294 
295 	/**
296 	 * Sets a boolean value indicating if the first proposed value must be automatically appended to the current entry.
297 	 * @param forceProposal if proposal has to be forced
298 	 */
299 	public void setForceProposal(boolean forceProposal) {
300 		engine.setProperty(Properties.FORCE_PROPOSAL, forceProposal);
301 	}
302 
303 	/**
304 	 * Sets a boolean value indicating if the first proposed value must be automatically appended to the current entry.
305 	 * @param forceProposal if proposal has to be forced
306 	 */
307 	/**
308 	 * Returns <code>true</code> if the attribute "forceProposal" is set.
309 	 * @return <code>true</code> if the attribute is set.
310 	 */
311 	public boolean isForceProposalSetted() {
312 		return engine.isPropertySetted(Properties.FORCE_PROPOSAL);
313 	}
314 
315 	/**
316 	 * Returns a string value containing the value for the selected select item object.
317 	 * @return value selected
318 	 */
319 	public Object getSuggestionValue() {
320 		return getSuggestionValue(null);
321 	}
322 
323 	/**
324 	 * Returns a string value containing the value for the selected select item object.
325 	 * @return value selected
326 	 */
327 	public Object getSuggestionValue(javax.faces.context.FacesContext facesContext) {
328 		return engine.getValue(Properties.SUGGESTION_VALUE, facesContext);
329 	}
330 
331 	/**
332 	 * Sets a string value containing the value for the selected select item object.
333 	 * @param suggestionValue value selected
334 	 */
335 	public void setSuggestionValue(Object suggestionValue) {
336 		engine.setValue(Properties.SUGGESTION_VALUE, suggestionValue);
337 	}
338 
339 	/**
340 	 * Sets a string value containing the value for the selected select item object.
341 	 * @param suggestionValue value selected
342 	 */
343 	/**
344 	 * Returns <code>true</code> if the attribute "suggestionValue" is set.
345 	 * @return <code>true</code> if the attribute is set.
346 	 */
347 	public boolean isSuggestionValueSetted() {
348 		return engine.isPropertySetted(Properties.SUGGESTION_VALUE);
349 	}
350 
351 	/**
352 	 * Returns a string specifying a converter id or a binding to a converter object. This converter will be used for the values of the list items.
353 	 * @return converter id
354 	 */
355 	public javax.faces.convert.Converter getSuggestionConverter() {
356 		return getSuggestionConverter(null);
357 	}
358 
359 	/**
360 	 * Returns a string specifying a converter id or a binding to a converter object. This converter will be used for the values of the list items.
361 	 * @return converter id
362 	 */
363 	public javax.faces.convert.Converter getSuggestionConverter(javax.faces.context.FacesContext facesContext) {
364 		return (javax.faces.convert.Converter)engine.getValue(Properties.SUGGESTION_CONVERTER, facesContext);
365 	}
366 
367 	/**
368 	 * Sets a string specifying a converter id or a binding to a converter object. This converter will be used for the values of the list items.
369 	 * @param suggestionConverter converter id
370 	 */
371 	public void setSuggestionConverter(javax.faces.convert.Converter suggestionConverter) {
372 		engine.setProperty(Properties.SUGGESTION_CONVERTER, suggestionConverter);
373 	}
374 
375 	/**
376 	 * Sets a string specifying a converter id or a binding to a converter object. This converter will be used for the values of the list items.
377 	 * @param suggestionConverter converter id
378 	 */
379 	/**
380 	 * Returns <code>true</code> if the attribute "suggestionConverter" is set.
381 	 * @return <code>true</code> if the attribute is set.
382 	 */
383 	public boolean isSuggestionConverterSetted() {
384 		return engine.isPropertySetted(Properties.SUGGESTION_CONVERTER);
385 	}
386 
387 	public String getMoreResultsMessage() {
388 		return getMoreResultsMessage(null);
389 	}
390 
391 	public String getMoreResultsMessage(javax.faces.context.FacesContext facesContext) {
392 		return engine.getStringProperty(Properties.MORE_RESULTS_MESSAGE, facesContext);
393 	}
394 
395 	public void setMoreResultsMessage(String moreResultsMessage) {
396 		engine.setProperty(Properties.MORE_RESULTS_MESSAGE, moreResultsMessage);
397 	}
398 
399 	/**
400 	 * Returns <code>true</code> if the attribute "moreResultsMessage" is set.
401 	 * @return <code>true</code> if the attribute is set.
402 	 */
403 	public boolean isMoreResultsMessageSetted() {
404 		return engine.isPropertySetted(Properties.MORE_RESULTS_MESSAGE);
405 	}
406 
407 	public boolean isOrderedItems() {
408 		return isOrderedItems(null);
409 	}
410 
411 	public boolean isOrderedItems(javax.faces.context.FacesContext facesContext) {
412 		return engine.getBoolProperty(Properties.ORDERED_ITEMS, true, facesContext);
413 	}
414 
415 	public void setOrderedItems(boolean orderedItems) {
416 		engine.setProperty(Properties.ORDERED_ITEMS, orderedItems);
417 	}
418 
419 	/**
420 	 * Returns <code>true</code> if the attribute "orderedItems" is set.
421 	 * @return <code>true</code> if the attribute is set.
422 	 */
423 	public boolean isOrderedItemsSetted() {
424 		return engine.isPropertySetted(Properties.ORDERED_ITEMS);
425 	}
426 
427 	protected Set getCameliaFields() {
428 		return CAMELIA_ATTRIBUTES;
429 	}
430 }