View Javadoc

1   package org.rcfaces.core.component;
2   
3   import org.rcfaces.core.component.capability.ISelectionEventCapability;
4   import org.rcfaces.core.internal.component.Properties;
5   import org.apache.commons.logging.LogFactory;
6   import org.rcfaces.core.component.AbstractCommandComponent;
7   import org.rcfaces.core.component.capability.IAlternateTextCapability;
8   import org.rcfaces.core.component.capability.IFocusStyleClassCapability;
9   import org.rcfaces.core.component.capability.ITextDirectionCapability;
10  import org.rcfaces.core.component.capability.IReadOnlyCapability;
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.component.capability.ITextCapability;
17  
18  /**
19   * <p>The button Component is equivalent to the standard HTML tag &lt;BUTTON&gt;.</p>
20   * <p>The button Component has the following capabilities :
21   * <ul>
22   * <li>ITextCapability</li>
23   * <li>ITextDirectionCapability</li>
24   * <li>ISelectionEventCapability</li>
25   * <li>IReadOnlyCapability</li>
26   * <li>IAlternateTextCapability</li>
27   * <li>IFocusStyleClassCapability</li>
28   * </ul>
29   * </p>
30   * 
31   * <p>The default <a href="/apidocs/index.html?org/rcfaces/core/component/ButtonComponent.html">button</a> renderer is linked to the <a href="/jsdocs/index.html?f_button.html" target="_blank">f_button</a> javascript class. f_box extends f_component, fa_asyncRender, fa_subMenu</p>
32   * 
33   * <p> Table of component style classes: </p>
34   * <table border="1" cellpadding="3" cellspacing="0" width="100%">
35   * <tbody>
36   * 
37   * <tr style="text-align:left">
38   * <th  width="33%">Style Name</th>
39   * <th width="50%">Description</th>
40   * </tr>
41   * 
42   * <tr  style="text-align:left">
43   * <td width="33%">f_button</td>
44   * <td width="50%">Defines styles for the wrapper Input element</td>
45   * </tr>
46   * 
47   * </tbody>
48   * </table>
49   */
50  public class ButtonComponent extends AbstractCommandComponent implements 
51  	ITextCapability,
52  	ITextDirectionCapability,
53  	ISelectionEventCapability,
54  	IReadOnlyCapability,
55  	IAlternateTextCapability,
56  	IFocusStyleClassCapability {
57  
58  	private static final Log LOG = LogFactory.getLog(ButtonComponent.class);
59  
60  	public static final String COMPONENT_TYPE="org.rcfaces.core.button";
61  
62  	protected static final Set CAMELIA_ATTRIBUTES=new HashSet(AbstractCommandComponent.CAMELIA_ATTRIBUTES);
63  	static {
64  		CAMELIA_ATTRIBUTES.addAll(Arrays.asList(new String[] {"focusStyleClass","selectionListener","text","readOnly","alternateText","textDirection"}));
65  	}
66  
67  	public ButtonComponent() {
68  		setRendererType(COMPONENT_TYPE);
69  	}
70  
71  	public ButtonComponent(String componentId) {
72  		this();
73  		setId(componentId);
74  	}
75  
76  	public java.lang.String getText() {
77  		return getText(null);
78  	}
79  
80  	/**
81  	 * See {@link #getText() getText()} for more details
82  	 */
83  	public java.lang.String getText(javax.faces.context.FacesContext facesContext) {
84  		return engine.getStringProperty(Properties.TEXT, facesContext);
85  	}
86  
87  	/**
88  	 * Returns <code>true</code> if the attribute "text" is set.
89  	 * @return <code>true</code> if the attribute is set.
90  	 */
91  	public final boolean isTextSetted() {
92  		return engine.isPropertySetted(Properties.TEXT);
93  	}
94  
95  	public void setText(java.lang.String text) {
96  		engine.setProperty(Properties.TEXT, text);
97  	}
98  
99  	public int getTextDirection() {
100 		return getTextDirection(null);
101 	}
102 
103 	/**
104 	 * See {@link #getTextDirection() getTextDirection()} for more details
105 	 */
106 	public int getTextDirection(javax.faces.context.FacesContext facesContext) {
107 		return engine.getIntProperty(Properties.TEXT_DIRECTION,0, facesContext);
108 	}
109 
110 	/**
111 	 * Returns <code>true</code> if the attribute "textDirection" is set.
112 	 * @return <code>true</code> if the attribute is set.
113 	 */
114 	public final boolean isTextDirectionSetted() {
115 		return engine.isPropertySetted(Properties.TEXT_DIRECTION);
116 	}
117 
118 	public void setTextDirection(int textDirection) {
119 		engine.setProperty(Properties.TEXT_DIRECTION, textDirection);
120 	}
121 
122 	public final void addSelectionListener(org.rcfaces.core.event.ISelectionListener listener) {
123 		addFacesListener(listener);
124 	}
125 
126 	public final void removeSelectionListener(org.rcfaces.core.event.ISelectionListener listener) {
127 		removeFacesListener(listener);
128 	}
129 
130 	public final javax.faces.event.FacesListener [] listSelectionListeners() {
131 		return getFacesListeners(org.rcfaces.core.event.ISelectionListener.class);
132 	}
133 
134 	public boolean isReadOnly() {
135 		return isReadOnly(null);
136 	}
137 
138 	/**
139 	 * See {@link #isReadOnly() isReadOnly()} for more details
140 	 */
141 	public boolean isReadOnly(javax.faces.context.FacesContext facesContext) {
142 		return engine.getBoolProperty(Properties.READ_ONLY, false, facesContext);
143 	}
144 
145 	/**
146 	 * Returns <code>true</code> if the attribute "readOnly" is set.
147 	 * @return <code>true</code> if the attribute is set.
148 	 */
149 	public final boolean isReadOnlySetted() {
150 		return engine.isPropertySetted(Properties.READ_ONLY);
151 	}
152 
153 	public void setReadOnly(boolean readOnly) {
154 		engine.setProperty(Properties.READ_ONLY, readOnly);
155 	}
156 
157 	public java.lang.String getAlternateText() {
158 		return getAlternateText(null);
159 	}
160 
161 	/**
162 	 * See {@link #getAlternateText() getAlternateText()} for more details
163 	 */
164 	public java.lang.String getAlternateText(javax.faces.context.FacesContext facesContext) {
165 		return engine.getStringProperty(Properties.ALTERNATE_TEXT, facesContext);
166 	}
167 
168 	/**
169 	 * Returns <code>true</code> if the attribute "alternateText" is set.
170 	 * @return <code>true</code> if the attribute is set.
171 	 */
172 	public final boolean isAlternateTextSetted() {
173 		return engine.isPropertySetted(Properties.ALTERNATE_TEXT);
174 	}
175 
176 	public void setAlternateText(java.lang.String alternateText) {
177 		engine.setProperty(Properties.ALTERNATE_TEXT, alternateText);
178 	}
179 
180 	public java.lang.String getFocusStyleClass() {
181 		return getFocusStyleClass(null);
182 	}
183 
184 	/**
185 	 * See {@link #getFocusStyleClass() getFocusStyleClass()} for more details
186 	 */
187 	public java.lang.String getFocusStyleClass(javax.faces.context.FacesContext facesContext) {
188 		return engine.getStringProperty(Properties.FOCUS_STYLE_CLASS, facesContext);
189 	}
190 
191 	/**
192 	 * Returns <code>true</code> if the attribute "focusStyleClass" is set.
193 	 * @return <code>true</code> if the attribute is set.
194 	 */
195 	public final boolean isFocusStyleClassSetted() {
196 		return engine.isPropertySetted(Properties.FOCUS_STYLE_CLASS);
197 	}
198 
199 	public void setFocusStyleClass(java.lang.String focusStyleClass) {
200 		engine.setProperty(Properties.FOCUS_STYLE_CLASS, focusStyleClass);
201 	}
202 
203 	protected Set getCameliaFields() {
204 		return CAMELIA_ATTRIBUTES;
205 	}
206 }