View Javadoc

1   package org.rcfaces.core.component;
2   
3   import org.rcfaces.core.internal.component.Properties;
4   import org.rcfaces.core.component.familly.IContentAccessors;
5   import org.rcfaces.core.component.capability.IImageCapability;
6   import java.lang.String;
7   import org.apache.commons.logging.LogFactory;
8   import org.rcfaces.core.component.capability.IImageSizeCapability;
9   import javax.faces.context.FacesContext;
10  import org.rcfaces.core.component.capability.IAlternateTextCapability;
11  import org.rcfaces.core.internal.tools.ImageAccessorTools;
12  import org.rcfaces.core.internal.converter.FilterPropertiesConverter;
13  import javax.el.ValueExpression;
14  import org.rcfaces.core.component.capability.IFilterCapability;
15  import java.util.HashSet;
16  import org.apache.commons.logging.Log;
17  import org.rcfaces.core.component.AbstractOutputComponent;
18  import org.rcfaces.core.model.IFilterProperties;
19  import java.util.Set;
20  import java.util.Arrays;
21  import org.rcfaces.core.internal.capability.IImageAccessorsCapability;
22  
23  /**
24   * <p>The image Component shows an image (it's equivalent to &lt;img .../&gt;).</p>
25   * <p>The image Component has the following capabilities :
26   * <ul>
27   * <li>IImageCapability</li>
28   * <li>IImageSizeCapability</li>
29   * <li>IAlternateTextCapability</li>
30   * <li>IFilterCapability</li>
31   * <li>IImageAccessorsCapability</li>      </ul>
32   * </p>
33   * 
34   * 
35   * 
36   * <p>The default <a href="/apidocs/index.html?org/rcfaces/core/component/ImageComponent.html">image</a> renderer is linked to the <a href="/jsdocs/index.html?f_image.html" target="_blank">f_image</a> javascript class. f_image extends f_filtredComponent</p>
37   * 
38   * <p> Table of component style classes: </p>
39   * <table border="1" cellpadding="3" cellspacing="0" width="100%">
40   * <tbody>
41   * 
42   * <tr style="text-align:left">
43   * <th  width="33%">Style Name</th>
44   * <th width="50%">Description</th>
45   * </tr>
46   * 
47   * <tr  style="text-align:left">
48   * <td width="33%">f_image</td>
49   * <td width="50%">Defines styles for the wrapper IMG element</td>
50   * </tr>
51   * 
52   * 
53   * </tbody>
54   * </table>
55   */
56  public class ImageComponent extends AbstractOutputComponent implements 
57  	IImageCapability,
58  	IImageSizeCapability,
59  	IAlternateTextCapability,
60  	IFilterCapability,
61  	IImageAccessorsCapability {
62  
63  	private static final Log LOG = LogFactory.getLog(ImageComponent.class);
64  
65  	public static final String COMPONENT_TYPE="org.rcfaces.core.image";
66  
67  	protected static final Set CAMELIA_ATTRIBUTES=new HashSet(AbstractOutputComponent.CAMELIA_ATTRIBUTES);
68  	static {
69  		CAMELIA_ATTRIBUTES.addAll(Arrays.asList(new String[] {"imageHeight","filterProperties","alternateText","imageWidth","imageURL"}));
70  	}
71  	protected static final String CAMELIA_VALUE_ALIAS="imageURL";
72  
73  	public ImageComponent() {
74  		setRendererType(COMPONENT_TYPE);
75  	}
76  
77  	public ImageComponent(String componentId) {
78  		this();
79  		setId(componentId);
80  	}
81  
82  	public IContentAccessors getImageAccessors(FacesContext facesContext) {
83  
84  
85  				Object value=getLocalValue();
86  				if (value==null) {
87  					value=getValueExpression(Properties.VALUE);
88  				}
89  			
90  				return ImageAccessorTools.createImageAccessor(facesContext, value);
91  			
92  	}
93  
94  	public void setFilterProperties(String properties) {
95  
96  
97  			IFilterProperties filterProperties=(IFilterProperties)FilterPropertiesConverter.SINGLETON.getAsObject(null, this, properties);
98  			
99  			setFilterProperties(filterProperties);
100 		
101 	}
102 
103 	public java.lang.String getImageURL() {
104 		return getImageURL(null);
105 	}
106 
107 	/**
108 	 * See {@link #getImageURL() getImageURL()} for more details
109 	 */
110 	public java.lang.String getImageURL(javax.faces.context.FacesContext facesContext) {
111 		return org.rcfaces.core.internal.tools.ValuesTools.valueToString(this, facesContext);
112 	}
113 
114 	/**
115 	 * Returns <code>true</code> if the attribute "imageURL" is set.
116 	 * @return <code>true</code> if the attribute is set.
117 	 */
118 	public final boolean isImageURLSetted() {
119 		return engine.isPropertySetted(Properties.IMAGE_URL);
120 	}
121 
122 	public void setImageURL(java.lang.String imageURL) {
123 		setValue(imageURL);
124 	}
125 
126 	public IContentAccessors getImageAccessors() {
127 
128 
129 			return getImageAccessors(null);
130 		
131 	}
132 
133 	public int getImageHeight() {
134 		return getImageHeight(null);
135 	}
136 
137 	/**
138 	 * See {@link #getImageHeight() getImageHeight()} for more details
139 	 */
140 	public int getImageHeight(javax.faces.context.FacesContext facesContext) {
141 		return engine.getIntProperty(Properties.IMAGE_HEIGHT,0, facesContext);
142 	}
143 
144 	/**
145 	 * Returns <code>true</code> if the attribute "imageHeight" is set.
146 	 * @return <code>true</code> if the attribute is set.
147 	 */
148 	public final boolean isImageHeightSetted() {
149 		return engine.isPropertySetted(Properties.IMAGE_HEIGHT);
150 	}
151 
152 	public void setImageHeight(int imageHeight) {
153 		engine.setProperty(Properties.IMAGE_HEIGHT, imageHeight);
154 	}
155 
156 	public int getImageWidth() {
157 		return getImageWidth(null);
158 	}
159 
160 	/**
161 	 * See {@link #getImageWidth() getImageWidth()} for more details
162 	 */
163 	public int getImageWidth(javax.faces.context.FacesContext facesContext) {
164 		return engine.getIntProperty(Properties.IMAGE_WIDTH,0, facesContext);
165 	}
166 
167 	/**
168 	 * Returns <code>true</code> if the attribute "imageWidth" is set.
169 	 * @return <code>true</code> if the attribute is set.
170 	 */
171 	public final boolean isImageWidthSetted() {
172 		return engine.isPropertySetted(Properties.IMAGE_WIDTH);
173 	}
174 
175 	public void setImageWidth(int imageWidth) {
176 		engine.setProperty(Properties.IMAGE_WIDTH, imageWidth);
177 	}
178 
179 	public java.lang.String getAlternateText() {
180 		return getAlternateText(null);
181 	}
182 
183 	/**
184 	 * See {@link #getAlternateText() getAlternateText()} for more details
185 	 */
186 	public java.lang.String getAlternateText(javax.faces.context.FacesContext facesContext) {
187 		return engine.getStringProperty(Properties.ALTERNATE_TEXT, facesContext);
188 	}
189 
190 	/**
191 	 * Returns <code>true</code> if the attribute "alternateText" is set.
192 	 * @return <code>true</code> if the attribute is set.
193 	 */
194 	public final boolean isAlternateTextSetted() {
195 		return engine.isPropertySetted(Properties.ALTERNATE_TEXT);
196 	}
197 
198 	public void setAlternateText(java.lang.String alternateText) {
199 		engine.setProperty(Properties.ALTERNATE_TEXT, alternateText);
200 	}
201 
202 	public org.rcfaces.core.model.IFilterProperties getFilterProperties() {
203 		return getFilterProperties(null);
204 	}
205 
206 	/**
207 	 * See {@link #getFilterProperties() getFilterProperties()} for more details
208 	 */
209 	public org.rcfaces.core.model.IFilterProperties getFilterProperties(javax.faces.context.FacesContext facesContext) {
210 		return (org.rcfaces.core.model.IFilterProperties)engine.getProperty(Properties.FILTER_PROPERTIES, facesContext);
211 	}
212 
213 	/**
214 	 * Returns <code>true</code> if the attribute "filterProperties" is set.
215 	 * @return <code>true</code> if the attribute is set.
216 	 */
217 	public final boolean isFilterPropertiesSetted() {
218 		return engine.isPropertySetted(Properties.FILTER_PROPERTIES);
219 	}
220 
221 	public void setFilterProperties(org.rcfaces.core.model.IFilterProperties filterProperties) {
222 		engine.setProperty(Properties.FILTER_PROPERTIES, filterProperties);
223 	}
224 
225 	protected Set getCameliaFields() {
226 		return CAMELIA_ATTRIBUTES;
227 	}
228 
229 	protected String getCameliaValueAlias() {
230 		return CAMELIA_VALUE_ALIAS;
231 	}
232 }