View Javadoc

1   package org.rcfaces.core.component;
2   
3   import org.rcfaces.core.internal.component.Properties;
4   import org.rcfaces.core.component.ButtonComponent;
5   import org.rcfaces.core.component.familly.IContentAccessors;
6   import java.lang.String;
7   import org.apache.commons.logging.LogFactory;
8   import javax.faces.context.FacesContext;
9   import org.rcfaces.core.internal.tools.ImageAccessorTools;
10  import org.rcfaces.core.component.capability.IHorizontalTextPositionCapability;
11  import javax.faces.convert.Converter;
12  import javax.el.ValueExpression;
13  import java.util.HashSet;
14  import org.apache.commons.logging.Log;
15  import java.util.Set;
16  import java.util.Arrays;
17  import org.rcfaces.core.internal.capability.IImageAccessorsCapability;
18  import org.rcfaces.core.component.familly.IImageButtonFamilly;
19  import org.rcfaces.core.internal.converter.TextPositionConverter;
20  
21  /**
22   * <p>The imageButton Component is a <a href="/comps/buttonComponent.html">button Component</a> that can show an image.</p>
23   * <p>The imageButton Component has the following capabilities :
24   * <ul>
25   * <li>IImageButtonFamilly </li>
26   * <li>IImageAccessorsCapability </li>
27   * </ul>
28   * </p>
29   * 
30   * 
31   * <p>The default <a href="/apidocs/index.html?org/rcfaces/core/component/ImageButtonComponent.html">imageButton</a> renderer is linked to the <a href="/jsdocs/index.html?f_imageButton.html" target="_blank">f_imageButton</a> javascript class. f_imageButton extends f_component, fa_readOnly, fa_disabled, fa_tabIndex, fa_borderType, fa_images, fa_immediate, fa_value, fa_aria</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_imageButton</td>
44   * <td width="50%">Defines styles for the wrapper IMG element</td>
45   * </tr>
46   * 
47   * <tr  style="text-align:left">
48   * <td width="33%">f_imageButton_text</td>
49   * <td width="50%">Defines styles for the wrapper SPAN element for text</td>
50   * </tr>
51   * 
52   * <tr  style="text-align:left">
53   * <td width="33%">f_imageButton_image</td>
54   * <td width="50%">Defines styles for the wrapper IMG element</td>
55   * </tr>
56   * 
57   * 
58   * </tbody>
59   * </table>
60   */
61  public class ImageButtonComponent extends ButtonComponent implements 
62  	IImageButtonFamilly,
63  	IImageAccessorsCapability {
64  
65  	private static final Log LOG = LogFactory.getLog(ImageButtonComponent.class);
66  
67  	public static final String COMPONENT_TYPE="org.rcfaces.core.imageButton";
68  
69  	protected static final Set CAMELIA_ATTRIBUTES=new HashSet(ButtonComponent.CAMELIA_ATTRIBUTES);
70  	static {
71  		CAMELIA_ATTRIBUTES.addAll(Arrays.asList(new String[] {"disabledImageURL","imageHeight","text","borderType","textPosition","hoverImageURL","tabIndex","selectedImageURL","selectionListener","readOnly","border","imageURL","disabled","imageWidth"}));
72  	}
73  
74  	public ImageButtonComponent() {
75  		setRendererType(COMPONENT_TYPE);
76  	}
77  
78  	public ImageButtonComponent(String componentId) {
79  		this();
80  		setId(componentId);
81  	}
82  
83  	public IContentAccessors getImageAccessors(FacesContext facesContext) {
84  
85  
86  			return ImageAccessorTools.createImageAccessors(facesContext, this, engine);
87  		
88  	}
89  
90  	protected Converter getTextPositionConverter() {
91  
92  
93  				return TextPositionConverter.SINGLETON;
94  			
95  	}
96  
97  	public void setTextPosition(String textPosition) {
98  
99  
100 			setTextPosition(((Integer)getTextPositionConverter().getAsObject(null, this, textPosition)).intValue());
101 		
102 	}
103 
104 	public java.lang.String getImageURL() {
105 		return getImageURL(null);
106 	}
107 
108 	/**
109 	 * See {@link #getImageURL() getImageURL()} for more details
110 	 */
111 	public java.lang.String getImageURL(javax.faces.context.FacesContext facesContext) {
112 		return engine.getStringProperty(Properties.IMAGE_URL, facesContext);
113 	}
114 
115 	/**
116 	 * Returns <code>true</code> if the attribute "imageURL" is set.
117 	 * @return <code>true</code> if the attribute is set.
118 	 */
119 	public final boolean isImageURLSetted() {
120 		return engine.isPropertySetted(Properties.IMAGE_URL);
121 	}
122 
123 	public void setImageURL(java.lang.String imageURL) {
124 		engine.setProperty(Properties.IMAGE_URL, imageURL);
125 	}
126 
127 	public java.lang.String getDisabledImageURL() {
128 		return getDisabledImageURL(null);
129 	}
130 
131 	/**
132 	 * See {@link #getDisabledImageURL() getDisabledImageURL()} for more details
133 	 */
134 	public java.lang.String getDisabledImageURL(javax.faces.context.FacesContext facesContext) {
135 		return engine.getStringProperty(Properties.DISABLED_IMAGE_URL, facesContext);
136 	}
137 
138 	/**
139 	 * Returns <code>true</code> if the attribute "disabledImageURL" is set.
140 	 * @return <code>true</code> if the attribute is set.
141 	 */
142 	public final boolean isDisabledImageURLSetted() {
143 		return engine.isPropertySetted(Properties.DISABLED_IMAGE_URL);
144 	}
145 
146 	public void setDisabledImageURL(java.lang.String disabledImageURL) {
147 		engine.setProperty(Properties.DISABLED_IMAGE_URL, disabledImageURL);
148 	}
149 
150 	public java.lang.String getHoverImageURL() {
151 		return getHoverImageURL(null);
152 	}
153 
154 	/**
155 	 * See {@link #getHoverImageURL() getHoverImageURL()} for more details
156 	 */
157 	public java.lang.String getHoverImageURL(javax.faces.context.FacesContext facesContext) {
158 		return engine.getStringProperty(Properties.HOVER_IMAGE_URL, facesContext);
159 	}
160 
161 	/**
162 	 * Returns <code>true</code> if the attribute "hoverImageURL" is set.
163 	 * @return <code>true</code> if the attribute is set.
164 	 */
165 	public final boolean isHoverImageURLSetted() {
166 		return engine.isPropertySetted(Properties.HOVER_IMAGE_URL);
167 	}
168 
169 	public void setHoverImageURL(java.lang.String hoverImageURL) {
170 		engine.setProperty(Properties.HOVER_IMAGE_URL, hoverImageURL);
171 	}
172 
173 	public java.lang.String getSelectedImageURL() {
174 		return getSelectedImageURL(null);
175 	}
176 
177 	/**
178 	 * See {@link #getSelectedImageURL() getSelectedImageURL()} for more details
179 	 */
180 	public java.lang.String getSelectedImageURL(javax.faces.context.FacesContext facesContext) {
181 		return engine.getStringProperty(Properties.SELECTED_IMAGE_URL, facesContext);
182 	}
183 
184 	/**
185 	 * Returns <code>true</code> if the attribute "selectedImageURL" is set.
186 	 * @return <code>true</code> if the attribute is set.
187 	 */
188 	public final boolean isSelectedImageURLSetted() {
189 		return engine.isPropertySetted(Properties.SELECTED_IMAGE_URL);
190 	}
191 
192 	public void setSelectedImageURL(java.lang.String selectedImageURL) {
193 		engine.setProperty(Properties.SELECTED_IMAGE_URL, selectedImageURL);
194 	}
195 
196 	public boolean isBorder() {
197 		return isBorder(null);
198 	}
199 
200 	/**
201 	 * See {@link #isBorder() isBorder()} for more details
202 	 */
203 	public boolean isBorder(javax.faces.context.FacesContext facesContext) {
204 		return engine.getBoolProperty(Properties.BORDER, true, facesContext);
205 	}
206 
207 	/**
208 	 * Returns <code>true</code> if the attribute "border" is set.
209 	 * @return <code>true</code> if the attribute is set.
210 	 */
211 	public final boolean isBorderSetted() {
212 		return engine.isPropertySetted(Properties.BORDER);
213 	}
214 
215 	public void setBorder(boolean border) {
216 		engine.setProperty(Properties.BORDER, border);
217 	}
218 
219 	public java.lang.String getBorderType() {
220 		return getBorderType(null);
221 	}
222 
223 	/**
224 	 * See {@link #getBorderType() getBorderType()} for more details
225 	 */
226 	public java.lang.String getBorderType(javax.faces.context.FacesContext facesContext) {
227 		return engine.getStringProperty(Properties.BORDER_TYPE, facesContext);
228 	}
229 
230 	/**
231 	 * Returns <code>true</code> if the attribute "borderType" is set.
232 	 * @return <code>true</code> if the attribute is set.
233 	 */
234 	public final boolean isBorderTypeSetted() {
235 		return engine.isPropertySetted(Properties.BORDER_TYPE);
236 	}
237 
238 	public void setBorderType(java.lang.String borderType) {
239 		engine.setProperty(Properties.BORDER_TYPE, borderType);
240 	}
241 
242 	public int getTextPosition() {
243 		return getTextPosition(null);
244 	}
245 
246 	/**
247 	 * See {@link #getTextPosition() getTextPosition()} for more details
248 	 */
249 	public int getTextPosition(javax.faces.context.FacesContext facesContext) {
250 		return engine.getIntProperty(Properties.TEXT_POSITION,IHorizontalTextPositionCapability.DEFAULT_POSITION, facesContext);
251 	}
252 
253 	/**
254 	 * Returns <code>true</code> if the attribute "textPosition" is set.
255 	 * @return <code>true</code> if the attribute is set.
256 	 */
257 	public final boolean isTextPositionSetted() {
258 		return engine.isPropertySetted(Properties.TEXT_POSITION);
259 	}
260 
261 	public void setTextPosition(int textPosition) {
262 		engine.setProperty(Properties.TEXT_POSITION, textPosition);
263 	}
264 
265 	public int getImageHeight() {
266 		return getImageHeight(null);
267 	}
268 
269 	/**
270 	 * See {@link #getImageHeight() getImageHeight()} for more details
271 	 */
272 	public int getImageHeight(javax.faces.context.FacesContext facesContext) {
273 		return engine.getIntProperty(Properties.IMAGE_HEIGHT,0, facesContext);
274 	}
275 
276 	/**
277 	 * Returns <code>true</code> if the attribute "imageHeight" is set.
278 	 * @return <code>true</code> if the attribute is set.
279 	 */
280 	public final boolean isImageHeightSetted() {
281 		return engine.isPropertySetted(Properties.IMAGE_HEIGHT);
282 	}
283 
284 	public void setImageHeight(int imageHeight) {
285 		engine.setProperty(Properties.IMAGE_HEIGHT, imageHeight);
286 	}
287 
288 	public int getImageWidth() {
289 		return getImageWidth(null);
290 	}
291 
292 	/**
293 	 * See {@link #getImageWidth() getImageWidth()} for more details
294 	 */
295 	public int getImageWidth(javax.faces.context.FacesContext facesContext) {
296 		return engine.getIntProperty(Properties.IMAGE_WIDTH,0, facesContext);
297 	}
298 
299 	/**
300 	 * Returns <code>true</code> if the attribute "imageWidth" is set.
301 	 * @return <code>true</code> if the attribute is set.
302 	 */
303 	public final boolean isImageWidthSetted() {
304 		return engine.isPropertySetted(Properties.IMAGE_WIDTH);
305 	}
306 
307 	public void setImageWidth(int imageWidth) {
308 		engine.setProperty(Properties.IMAGE_WIDTH, imageWidth);
309 	}
310 
311 	public IContentAccessors getImageAccessors() {
312 
313 
314 			return getImageAccessors(null);
315 		
316 	}
317 
318 	protected Set getCameliaFields() {
319 		return CAMELIA_ATTRIBUTES;
320 	}
321 }