View Javadoc

1   package org.rcfaces.core.component;
2   
3   import org.rcfaces.core.component.iterator.IMenuIterator;
4   import org.rcfaces.core.component.capability.ISelectionEventCapability;
5   import org.rcfaces.core.internal.component.Properties;
6   import java.lang.String;
7   import org.apache.commons.logging.LogFactory;
8   import org.rcfaces.core.internal.tools.MenuTools;
9   import org.rcfaces.core.component.capability.IRequiredCapability;
10  import org.rcfaces.core.component.capability.IAlternateTextCapability;
11  import org.rcfaces.core.component.capability.IEmptyMessageCapability;
12  import org.rcfaces.core.component.capability.IFocusStyleClassCapability;
13  import org.rcfaces.core.component.IMenuComponent;
14  import org.rcfaces.core.component.capability.ITextDirectionCapability;
15  import org.rcfaces.core.component.capability.IReadOnlyCapability;
16  import javax.el.ValueExpression;
17  import java.util.HashSet;
18  import org.apache.commons.logging.Log;
19  import org.rcfaces.core.component.capability.IMaxTextLengthCapability;
20  import java.util.Set;
21  import java.util.Arrays;
22  import org.rcfaces.core.component.capability.IValueChangeEventCapability;
23  import org.rcfaces.core.component.AbstractInputComponent;
24  import org.rcfaces.core.component.capability.IMenuCapability;
25  import org.rcfaces.core.component.capability.ISeverityStyleClassCapability;
26  import org.rcfaces.core.component.capability.ITextCapability;
27  
28  /**
29   * <p>The textAreaEntry Component is based on the standard HTML tag &lt;TEXTAREA&gt; and is a <a href="/comps/textEntryComponent.html">textEntry Component</a>.</p>
30   * <p>The textAreaEntry Component has the following capabilities :
31   * <ul>
32   * <li>IRequiredCapability</li>
33   * <li>ITextCapability</li>
34   * <li>ITextDirectionCapability</li>
35   * <li>IEmptyMessageCapability</li>
36   * <li>IReadOnlyCapability</li>
37   * <li>IValueChangeEventCapability</li>
38   * <li>IMenuCapability</li>
39   * <li>IFocusStyleClassCapability</li>
40   * <li>ISeverityStyleClassCapability</li>
41   * <li>ISelectionEventCapability</li>
42   * <li>IAlternateTextCapability</li>
43   * <li>IMaxTextLengthCapability </li>
44   * </ul>
45   * </p>
46   * 
47   * <p>The default <a href="/apidocs/index.html?org/rcfaces/core/component/TextAreaComponent.html">textArea</a> renderer is linked to the <a href="/jsdocs/index.html?f_textArea.html" target="_blank">f_textArea</a> javascript class. f_textArea extends f_abstractEntry</p>
48   * 
49   * <p> Table of component style classes: </p>
50   * <table border="1" cellpadding="3" cellspacing="0" width="100%">
51   * <tbody>
52   * 
53   * <tr style="text-align:left">
54   * <th  width="33%">Style Name</th>
55   * <th width="50%">Description</th>
56   * </tr>
57   * 
58   * <tr  style="text-align:left">
59   * <td width="33%">f_textArea</td>
60   * <td width="50%">Defines styles for the wrapper element</td>
61   * </tr>
62   * 
63   * </tbody>
64   * </table>
65   */
66  public class TextAreaComponent extends AbstractInputComponent implements 
67  	IRequiredCapability,
68  	ITextCapability,
69  	ITextDirectionCapability,
70  	IEmptyMessageCapability,
71  	IReadOnlyCapability,
72  	IValueChangeEventCapability,
73  	IMenuCapability,
74  	IFocusStyleClassCapability,
75  	ISeverityStyleClassCapability,
76  	ISelectionEventCapability,
77  	IAlternateTextCapability,
78  	IMaxTextLengthCapability {
79  
80  	private static final Log LOG = LogFactory.getLog(TextAreaComponent.class);
81  
82  	public static final String COMPONENT_TYPE="org.rcfaces.core.textArea";
83  
84  	protected static final Set CAMELIA_ATTRIBUTES=new HashSet(AbstractInputComponent.CAMELIA_ATTRIBUTES);
85  	static {
86  		CAMELIA_ATTRIBUTES.addAll(Arrays.asList(new String[] {"focusStyleClass","text","fatalStyleClass","styleClass","rowNumber","columnNumber","textDirection","emptyMessage","selectionListener","maxTextLength","valueChangeListener","readOnly","errorStyleClass","warnStyleClass","alternateText","infoStyleClass","ignoreWhenFull","required"}));
87  	}
88  	protected static final String CAMELIA_VALUE_ALIAS="text";
89  
90  	public TextAreaComponent() {
91  		setRendererType(COMPONENT_TYPE);
92  	}
93  
94  	public TextAreaComponent(String componentId) {
95  		this();
96  		setId(componentId);
97  	}
98  
99  	public java.lang.String getText() {
100 		return getText(null);
101 	}
102 
103 	/**
104 	 * See {@link #getText() getText()} for more details
105 	 */
106 	public java.lang.String getText(javax.faces.context.FacesContext facesContext) {
107 		return org.rcfaces.core.internal.tools.ValuesTools.valueToString(this, facesContext);
108 	}
109 
110 	/**
111 	 * Returns <code>true</code> if the attribute "text" is set.
112 	 * @return <code>true</code> if the attribute is set.
113 	 */
114 	public final boolean isTextSetted() {
115 		return engine.isPropertySetted(Properties.TEXT);
116 	}
117 
118 	public void setText(java.lang.String text) {
119 		if (org.rcfaces.core.internal.listener.CameliaPhaseListener.isApplyingRequestValues()) {
120 			setSubmittedExternalValue(text);
121 		} else {
122 			setValue(text);
123 		}
124 	}
125 
126 	public int getTextDirection() {
127 		return getTextDirection(null);
128 	}
129 
130 	/**
131 	 * See {@link #getTextDirection() getTextDirection()} for more details
132 	 */
133 	public int getTextDirection(javax.faces.context.FacesContext facesContext) {
134 		return engine.getIntProperty(Properties.TEXT_DIRECTION,0, facesContext);
135 	}
136 
137 	/**
138 	 * Returns <code>true</code> if the attribute "textDirection" is set.
139 	 * @return <code>true</code> if the attribute is set.
140 	 */
141 	public final boolean isTextDirectionSetted() {
142 		return engine.isPropertySetted(Properties.TEXT_DIRECTION);
143 	}
144 
145 	public void setTextDirection(int textDirection) {
146 		engine.setProperty(Properties.TEXT_DIRECTION, textDirection);
147 	}
148 
149 	public java.lang.String getEmptyMessage() {
150 		return getEmptyMessage(null);
151 	}
152 
153 	/**
154 	 * See {@link #getEmptyMessage() getEmptyMessage()} for more details
155 	 */
156 	public java.lang.String getEmptyMessage(javax.faces.context.FacesContext facesContext) {
157 		return engine.getStringProperty(Properties.EMPTY_MESSAGE, facesContext);
158 	}
159 
160 	/**
161 	 * Returns <code>true</code> if the attribute "emptyMessage" is set.
162 	 * @return <code>true</code> if the attribute is set.
163 	 */
164 	public final boolean isEmptyMessageSetted() {
165 		return engine.isPropertySetted(Properties.EMPTY_MESSAGE);
166 	}
167 
168 	public void setEmptyMessage(java.lang.String emptyMessage) {
169 		engine.setProperty(Properties.EMPTY_MESSAGE, emptyMessage);
170 	}
171 
172 	public boolean isReadOnly() {
173 		return isReadOnly(null);
174 	}
175 
176 	/**
177 	 * See {@link #isReadOnly() isReadOnly()} for more details
178 	 */
179 	public boolean isReadOnly(javax.faces.context.FacesContext facesContext) {
180 		return engine.getBoolProperty(Properties.READ_ONLY, false, facesContext);
181 	}
182 
183 	/**
184 	 * Returns <code>true</code> if the attribute "readOnly" is set.
185 	 * @return <code>true</code> if the attribute is set.
186 	 */
187 	public final boolean isReadOnlySetted() {
188 		return engine.isPropertySetted(Properties.READ_ONLY);
189 	}
190 
191 	public void setReadOnly(boolean readOnly) {
192 		engine.setProperty(Properties.READ_ONLY, readOnly);
193 	}
194 
195 	public final void addValueChangeListener(javax.faces.event.ValueChangeListener listener) {
196 		addFacesListener(listener);
197 	}
198 
199 	public final void removeValueChangeListener(javax.faces.event.ValueChangeListener listener) {
200 		removeFacesListener(listener);
201 	}
202 
203 	public final javax.faces.event.FacesListener [] listValueChangeListeners() {
204 		return getFacesListeners(javax.faces.event.ValueChangeListener.class);
205 	}
206 
207 	public IMenuComponent getMenu() {
208 
209 
210 		return MenuTools.getMenu(this);
211 		
212 	}
213 
214 	public IMenuComponent getMenu(String menuId) {
215 
216 
217 		return MenuTools.getMenu(this, menuId);
218 		
219 	}
220 
221 	public IMenuIterator listMenus() {
222 
223 
224 		return MenuTools.listMenus(this);
225 		
226 	}
227 
228 	public java.lang.String getFocusStyleClass() {
229 		return getFocusStyleClass(null);
230 	}
231 
232 	/**
233 	 * See {@link #getFocusStyleClass() getFocusStyleClass()} for more details
234 	 */
235 	public java.lang.String getFocusStyleClass(javax.faces.context.FacesContext facesContext) {
236 		return engine.getStringProperty(Properties.FOCUS_STYLE_CLASS, facesContext);
237 	}
238 
239 	/**
240 	 * Returns <code>true</code> if the attribute "focusStyleClass" is set.
241 	 * @return <code>true</code> if the attribute is set.
242 	 */
243 	public final boolean isFocusStyleClassSetted() {
244 		return engine.isPropertySetted(Properties.FOCUS_STYLE_CLASS);
245 	}
246 
247 	public void setFocusStyleClass(java.lang.String focusStyleClass) {
248 		engine.setProperty(Properties.FOCUS_STYLE_CLASS, focusStyleClass);
249 	}
250 
251 	public java.lang.String getErrorStyleClass() {
252 		return getErrorStyleClass(null);
253 	}
254 
255 	/**
256 	 * See {@link #getErrorStyleClass() getErrorStyleClass()} for more details
257 	 */
258 	public java.lang.String getErrorStyleClass(javax.faces.context.FacesContext facesContext) {
259 		return engine.getStringProperty(Properties.ERROR_STYLE_CLASS, facesContext);
260 	}
261 
262 	/**
263 	 * Returns <code>true</code> if the attribute "errorStyleClass" is set.
264 	 * @return <code>true</code> if the attribute is set.
265 	 */
266 	public final boolean isErrorStyleClassSetted() {
267 		return engine.isPropertySetted(Properties.ERROR_STYLE_CLASS);
268 	}
269 
270 	public void setErrorStyleClass(java.lang.String errorStyleClass) {
271 		engine.setProperty(Properties.ERROR_STYLE_CLASS, errorStyleClass);
272 	}
273 
274 	public java.lang.String getFatalStyleClass() {
275 		return getFatalStyleClass(null);
276 	}
277 
278 	/**
279 	 * See {@link #getFatalStyleClass() getFatalStyleClass()} for more details
280 	 */
281 	public java.lang.String getFatalStyleClass(javax.faces.context.FacesContext facesContext) {
282 		return engine.getStringProperty(Properties.FATAL_STYLE_CLASS, facesContext);
283 	}
284 
285 	/**
286 	 * Returns <code>true</code> if the attribute "fatalStyleClass" is set.
287 	 * @return <code>true</code> if the attribute is set.
288 	 */
289 	public final boolean isFatalStyleClassSetted() {
290 		return engine.isPropertySetted(Properties.FATAL_STYLE_CLASS);
291 	}
292 
293 	public void setFatalStyleClass(java.lang.String fatalStyleClass) {
294 		engine.setProperty(Properties.FATAL_STYLE_CLASS, fatalStyleClass);
295 	}
296 
297 	public java.lang.String getInfoStyleClass() {
298 		return getInfoStyleClass(null);
299 	}
300 
301 	/**
302 	 * See {@link #getInfoStyleClass() getInfoStyleClass()} for more details
303 	 */
304 	public java.lang.String getInfoStyleClass(javax.faces.context.FacesContext facesContext) {
305 		return engine.getStringProperty(Properties.INFO_STYLE_CLASS, facesContext);
306 	}
307 
308 	/**
309 	 * Returns <code>true</code> if the attribute "infoStyleClass" is set.
310 	 * @return <code>true</code> if the attribute is set.
311 	 */
312 	public final boolean isInfoStyleClassSetted() {
313 		return engine.isPropertySetted(Properties.INFO_STYLE_CLASS);
314 	}
315 
316 	public void setInfoStyleClass(java.lang.String infoStyleClass) {
317 		engine.setProperty(Properties.INFO_STYLE_CLASS, infoStyleClass);
318 	}
319 
320 	public java.lang.String getWarnStyleClass() {
321 		return getWarnStyleClass(null);
322 	}
323 
324 	/**
325 	 * See {@link #getWarnStyleClass() getWarnStyleClass()} for more details
326 	 */
327 	public java.lang.String getWarnStyleClass(javax.faces.context.FacesContext facesContext) {
328 		return engine.getStringProperty(Properties.WARN_STYLE_CLASS, facesContext);
329 	}
330 
331 	/**
332 	 * Returns <code>true</code> if the attribute "warnStyleClass" is set.
333 	 * @return <code>true</code> if the attribute is set.
334 	 */
335 	public final boolean isWarnStyleClassSetted() {
336 		return engine.isPropertySetted(Properties.WARN_STYLE_CLASS);
337 	}
338 
339 	public void setWarnStyleClass(java.lang.String warnStyleClass) {
340 		engine.setProperty(Properties.WARN_STYLE_CLASS, warnStyleClass);
341 	}
342 
343 	public final void addSelectionListener(org.rcfaces.core.event.ISelectionListener listener) {
344 		addFacesListener(listener);
345 	}
346 
347 	public final void removeSelectionListener(org.rcfaces.core.event.ISelectionListener listener) {
348 		removeFacesListener(listener);
349 	}
350 
351 	public final javax.faces.event.FacesListener [] listSelectionListeners() {
352 		return getFacesListeners(org.rcfaces.core.event.ISelectionListener.class);
353 	}
354 
355 	public java.lang.String getAlternateText() {
356 		return getAlternateText(null);
357 	}
358 
359 	/**
360 	 * See {@link #getAlternateText() getAlternateText()} for more details
361 	 */
362 	public java.lang.String getAlternateText(javax.faces.context.FacesContext facesContext) {
363 		return engine.getStringProperty(Properties.ALTERNATE_TEXT, facesContext);
364 	}
365 
366 	/**
367 	 * Returns <code>true</code> if the attribute "alternateText" is set.
368 	 * @return <code>true</code> if the attribute is set.
369 	 */
370 	public final boolean isAlternateTextSetted() {
371 		return engine.isPropertySetted(Properties.ALTERNATE_TEXT);
372 	}
373 
374 	public void setAlternateText(java.lang.String alternateText) {
375 		engine.setProperty(Properties.ALTERNATE_TEXT, alternateText);
376 	}
377 
378 	public int getMaxTextLength() {
379 		return getMaxTextLength(null);
380 	}
381 
382 	/**
383 	 * See {@link #getMaxTextLength() getMaxTextLength()} for more details
384 	 */
385 	public int getMaxTextLength(javax.faces.context.FacesContext facesContext) {
386 		return engine.getIntProperty(Properties.MAX_TEXT_LENGTH,0, facesContext);
387 	}
388 
389 	/**
390 	 * Returns <code>true</code> if the attribute "maxTextLength" is set.
391 	 * @return <code>true</code> if the attribute is set.
392 	 */
393 	public final boolean isMaxTextLengthSetted() {
394 		return engine.isPropertySetted(Properties.MAX_TEXT_LENGTH);
395 	}
396 
397 	public void setMaxTextLength(int maxTextLength) {
398 		engine.setProperty(Properties.MAX_TEXT_LENGTH, maxTextLength);
399 	}
400 
401 	/**
402 	 * Returns an int value holding the width of the component in characters : x characters translates into y pixels width.
403 	 * @return width in characters
404 	 */
405 	public int getColumnNumber() {
406 		return getColumnNumber(null);
407 	}
408 
409 	/**
410 	 * Returns an int value holding the width of the component in characters : x characters translates into y pixels width.
411 	 * @return width in characters
412 	 */
413 	public int getColumnNumber(javax.faces.context.FacesContext facesContext) {
414 		return engine.getIntProperty(Properties.COLUMN_NUMBER, 0, facesContext);
415 	}
416 
417 	/**
418 	 * Sets an int value holding the width of the component in characters : x characters translates into y pixels width.
419 	 * @param columnNumber width in characters
420 	 */
421 	public void setColumnNumber(int columnNumber) {
422 		engine.setProperty(Properties.COLUMN_NUMBER, columnNumber);
423 	}
424 
425 	/**
426 	 * Sets an int value holding the width of the component in characters : x characters translates into y pixels width.
427 	 * @param columnNumber width in characters
428 	 */
429 	/**
430 	 * Returns <code>true</code> if the attribute "columnNumber" is set.
431 	 * @return <code>true</code> if the attribute is set.
432 	 */
433 	public boolean isColumnNumberSetted() {
434 		return engine.isPropertySetted(Properties.COLUMN_NUMBER);
435 	}
436 
437 	/**
438 	 * Returns an int value specifying the number of rows to be displayed.
439 	 * @return number of rows
440 	 */
441 	public int getRowNumber() {
442 		return getRowNumber(null);
443 	}
444 
445 	/**
446 	 * Returns an int value specifying the number of rows to be displayed.
447 	 * @return number of rows
448 	 */
449 	public int getRowNumber(javax.faces.context.FacesContext facesContext) {
450 		return engine.getIntProperty(Properties.ROW_NUMBER, 0, facesContext);
451 	}
452 
453 	/**
454 	 * Sets an int value specifying the number of rows to be displayed.
455 	 * @param rowNumber number of rows
456 	 */
457 	public void setRowNumber(int rowNumber) {
458 		engine.setProperty(Properties.ROW_NUMBER, rowNumber);
459 	}
460 
461 	/**
462 	 * Sets an int value specifying the number of rows to be displayed.
463 	 * @param rowNumber number of rows
464 	 */
465 	/**
466 	 * Returns <code>true</code> if the attribute "rowNumber" is set.
467 	 * @return <code>true</code> if the attribute is set.
468 	 */
469 	public boolean isRowNumberSetted() {
470 		return engine.isPropertySetted(Properties.ROW_NUMBER);
471 	}
472 
473 	public boolean isIgnoreWhenFull() {
474 		return isIgnoreWhenFull(null);
475 	}
476 
477 	public boolean isIgnoreWhenFull(javax.faces.context.FacesContext facesContext) {
478 		return engine.getBoolProperty(Properties.IGNORE_WHEN_FULL, false, facesContext);
479 	}
480 
481 	public void setIgnoreWhenFull(boolean ignoreWhenFull) {
482 		engine.setProperty(Properties.IGNORE_WHEN_FULL, ignoreWhenFull);
483 	}
484 
485 	/**
486 	 * Returns <code>true</code> if the attribute "ignoreWhenFull" is set.
487 	 * @return <code>true</code> if the attribute is set.
488 	 */
489 	public boolean isIgnoreWhenFullSetted() {
490 		return engine.isPropertySetted(Properties.IGNORE_WHEN_FULL);
491 	}
492 
493 	protected Set getCameliaFields() {
494 		return CAMELIA_ATTRIBUTES;
495 	}
496 
497 	protected String getCameliaValueAlias() {
498 		return CAMELIA_VALUE_ALIAS;
499 	}
500 }