1 16 package org.apache.myfaces.custom.swapimage; 17 18 import org.apache.myfaces.component.UserRoleUtils; 19 20 import javax.faces.component.UIGraphic; 21 import javax.faces.el.ValueBinding; 22 import javax.faces.context.FacesContext; 23 24 35 public class HtmlSwapImage extends UIGraphic 36 { 37 38 40 public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlSwapImage"; 41 public static final String COMPONENT_FAMILY = "javax.faces.Graphic"; 42 private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.SwapImage"; 43 private static final boolean DEFAULT_ISMAP = false; 44 45 private String _swapImageUrl = null; 46 private String _activeImageUrl = null; 47 private String _alt = null; 48 private String _dir = null; 49 private String _height = null; 50 private Boolean _ismap = null; 51 private String _lang = null; 52 private String _longdesc = null; 53 private String _onclick = null; 54 private String _ondblclick = null; 55 private String _onkeydown = null; 56 private String _onkeypress = null; 57 private String _onkeyup = null; 58 private String _style = null; 59 private String _styleClass = null; 60 private String _title = null; 61 private String _usemap = null; 62 private String _width = null; 63 64 public HtmlSwapImage() 65 { 66 setRendererType(DEFAULT_RENDERER_TYPE); 67 } 68 69 public String getFamily() 70 { 71 return COMPONENT_FAMILY; 72 } 73 74 public void setSwapImageUrl(String swapImageUrl) 75 { 76 _swapImageUrl = swapImageUrl; 77 } 78 79 public String getSwapImageUrl() 80 { 81 if (_swapImageUrl != null) return _swapImageUrl; 82 ValueBinding vb = getValueBinding("swapImageUrl"); 83 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 84 } 85 86 public void setActiveImageUrl(String activeImageUrl) 87 { 88 _activeImageUrl = activeImageUrl; 89 } 90 91 public String getActiveImageUrl() 92 { 93 if (_activeImageUrl != null) return _activeImageUrl; 94 ValueBinding vb = getValueBinding("activeImageUrl"); 95 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 96 } 97 98 public void setAlt(String alt) 99 { 100 _alt = alt; 101 } 102 103 public String getAlt() 104 { 105 if (_alt != null) return _alt; 106 ValueBinding vb = getValueBinding("alt"); 107 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 108 } 109 110 public void setDir(String dir) 111 { 112 _dir = dir; 113 } 114 115 public String getDir() 116 { 117 if (_dir != null) return _dir; 118 ValueBinding vb = getValueBinding("dir"); 119 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 120 } 121 122 public void setHeight(String height) 123 { 124 _height = height; 125 } 126 127 public String getHeight() 128 { 129 if (_height != null) return _height; 130 ValueBinding vb = getValueBinding("height"); 131 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 132 } 133 134 public void setIsmap(boolean ismap) 135 { 136 _ismap = Boolean.valueOf(ismap); 137 } 138 139 public boolean isIsmap() 140 { 141 if (_ismap != null) return _ismap.booleanValue(); 142 ValueBinding vb = getValueBinding("ismap"); 143 Boolean v = vb != null ? (Boolean )vb.getValue(getFacesContext()) : null; 144 return v != null ? v.booleanValue() : DEFAULT_ISMAP; 145 } 146 147 public void setLang(String lang) 148 { 149 _lang = lang; 150 } 151 152 public String getLang() 153 { 154 if (_lang != null) return _lang; 155 ValueBinding vb = getValueBinding("lang"); 156 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 157 } 158 159 public void setLongdesc(String longdesc) 160 { 161 _longdesc = longdesc; 162 } 163 164 public String getLongdesc() 165 { 166 if (_longdesc != null) return _longdesc; 167 ValueBinding vb = getValueBinding("longdesc"); 168 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 169 } 170 171 public void setOnclick(String onclick) 172 { 173 _onclick = onclick; 174 } 175 176 public String getOnclick() 177 { 178 if (_onclick != null) return _onclick; 179 ValueBinding vb = getValueBinding("onclick"); 180 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 181 } 182 183 public void setOndblclick(String ondblclick) 184 { 185 _ondblclick = ondblclick; 186 } 187 188 public String getOndblclick() 189 { 190 if (_ondblclick != null) return _ondblclick; 191 ValueBinding vb = getValueBinding("ondblclick"); 192 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 193 } 194 195 public void setOnkeydown(String onkeydown) 196 { 197 _onkeydown = onkeydown; 198 } 199 200 public String getOnkeydown() 201 { 202 if (_onkeydown != null) return _onkeydown; 203 ValueBinding vb = getValueBinding("onkeydown"); 204 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 205 } 206 207 public void setOnkeypress(String onkeypress) 208 { 209 _onkeypress = onkeypress; 210 } 211 212 public String getOnkeypress() 213 { 214 if (_onkeypress != null) return _onkeypress; 215 ValueBinding vb = getValueBinding("onkeypress"); 216 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 217 } 218 219 public void setOnkeyup(String onkeyup) 220 { 221 _onkeyup = onkeyup; 222 } 223 224 public String getOnkeyup() 225 { 226 if (_onkeyup != null) return _onkeyup; 227 ValueBinding vb = getValueBinding("onkeyup"); 228 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 229 } 230 231 public void setStyle(String style) 232 { 233 _style = style; 234 } 235 236 public String getStyle() 237 { 238 if (_style != null) return _style; 239 ValueBinding vb = getValueBinding("style"); 240 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 241 } 242 243 public void setStyleClass(String styleClass) 244 { 245 _styleClass = styleClass; 246 } 247 248 public String getStyleClass() 249 { 250 if (_styleClass != null) return _styleClass; 251 ValueBinding vb = getValueBinding("styleClass"); 252 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 253 } 254 255 public void setTitle(String title) 256 { 257 _title = title; 258 } 259 260 public String getTitle() 261 { 262 if (_title != null) return _title; 263 ValueBinding vb = getValueBinding("title"); 264 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 265 } 266 267 public void setUsemap(String usemap) 268 { 269 _usemap = usemap; 270 } 271 272 public String getUsemap() 273 { 274 if (_usemap != null) return _usemap; 275 ValueBinding vb = getValueBinding("usemap"); 276 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 277 } 278 279 public void setWidth(String width) 280 { 281 _width = width; 282 } 283 284 public String getWidth() 285 { 286 if (_width != null) return _width; 287 ValueBinding vb = getValueBinding("width"); 288 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 289 } 290 291 292 public boolean isRendered() 293 { 294 if (!UserRoleUtils.isVisibleOnUserRole(this)) return false; 295 return super.isRendered(); 296 } 297 298 public Object saveState(FacesContext context) 299 { 300 Object values[] = new Object [19]; 301 values[0] = super.saveState(context); 302 values[1] = _swapImageUrl; 303 values[2] = _activeImageUrl; 304 values[3] = _alt; 305 values[4] = _dir; 306 values[5] = _height; 307 values[6] = _ismap; 308 values[7] = _lang; 309 values[8] = _longdesc; 310 values[9] = _onclick; 311 values[10] = _ondblclick; 312 values[11] = _onkeydown; 313 values[12] = _onkeypress; 314 values[13] = _onkeyup; 315 values[14] = _style; 316 values[15] = _styleClass; 317 values[16] = _title; 318 values[17] = _usemap; 319 values[18] = _width; 320 return ((Object ) (values)); 321 } 322 323 public void restoreState(FacesContext context, Object state) 324 { 325 Object values[] = (Object [])state; 326 super.restoreState(context, values[0]); 327 _swapImageUrl = (String )values[1]; 328 _activeImageUrl = (String )values[2]; 329 _alt = (String )values[3]; 330 _dir = (String )values[4]; 331 _height = (String )values[5]; 332 _ismap = (Boolean )values[6]; 333 _lang = (String )values[7]; 334 _longdesc = (String )values[8]; 335 _onclick = (String )values[9]; 336 _ondblclick = (String )values[10]; 337 _onkeydown = (String )values[11]; 338 _onkeypress = (String )values[12]; 339 _onkeyup = (String )values[13]; 340 _style = (String )values[14]; 341 _styleClass = (String )values[15]; 342 _title = (String )values[16]; 343 _usemap = (String )values[17]; 344 _width = (String )values[18]; 345 } 346 } 348 | Popular Tags |