1 16 package org.apache.cocoon.faces.taglib.html; 17 18 import org.apache.cocoon.faces.FacesUtils; 19 import org.apache.cocoon.faces.taglib.UIComponentTag; 20 import org.apache.commons.lang.BooleanUtils; 21 22 import javax.faces.FacesException; 23 import javax.faces.component.UICommand; 24 import javax.faces.component.UIComponent; 25 import javax.faces.el.MethodBinding; 26 import javax.faces.event.ActionEvent; 27 28 31 public class CommandLinkTag extends UIComponentTag { 32 33 private String action; 34 private String actionListener; 35 private String immediate; 36 private String value; 37 private String accesskey; 38 private String charset; 39 private String coords; 40 private String dir; 41 private String hreflang; 42 private String lang; 43 private String onblur; 44 private String ondblclick; 45 private String onfocus; 46 private String onkeydown; 47 private String onkeypress; 48 private String onkeyup; 49 private String onmousedown; 50 private String onmousemove; 51 private String onmouseout; 52 private String onmouseover; 53 private String onmouseup; 54 private String rel; 55 private String rev; 56 private String shape; 57 private String style; 58 private String styleClass; 59 private String tabindex; 60 private String target; 61 private String title; 62 private String type; 63 64 65 public void setAction(String action) { 66 this.action = action; 67 } 68 69 public void setActionListener(String actionListener) { 70 this.actionListener = actionListener; 71 } 72 73 public void setImmediate(String immediate) { 74 this.immediate = immediate; 75 } 76 77 public void setValue(String value) { 78 this.value = value; 79 } 80 81 public void setAccesskey(String accesskey) { 82 this.accesskey = accesskey; 83 } 84 85 public void setCharset(String charset) { 86 this.charset = charset; 87 } 88 89 public void setCoords(String coords) { 90 this.coords = coords; 91 } 92 93 public void setDir(String dir) { 94 this.dir = dir; 95 } 96 97 public void setHreflang(String hreflang) { 98 this.hreflang = hreflang; 99 } 100 101 public void setLang(String lang) { 102 this.lang = lang; 103 } 104 105 public void setOnblur(String onblur) { 106 this.onblur = onblur; 107 } 108 109 public void setOndblclick(String ondblclick) { 110 this.ondblclick = ondblclick; 111 } 112 113 public void setOnfocus(String onfocus) { 114 this.onfocus = onfocus; 115 } 116 117 public void setOnkeydown(String onkeydown) { 118 this.onkeydown = onkeydown; 119 } 120 121 public void setOnkeypress(String onkeypress) { 122 this.onkeypress = onkeypress; 123 } 124 125 public void setOnkeyup(String onkeyup) { 126 this.onkeyup = onkeyup; 127 } 128 129 public void setOnmousedown(String onmousedown) { 130 this.onmousedown = onmousedown; 131 } 132 133 public void setOnmousemove(String onmousemove) { 134 this.onmousemove = onmousemove; 135 } 136 137 public void setOnmouseout(String onmouseout) { 138 this.onmouseout = onmouseout; 139 } 140 141 public void setOnmouseover(String onmouseover) { 142 this.onmouseover = onmouseover; 143 } 144 145 public void setOnmouseup(String onmouseup) { 146 this.onmouseup = onmouseup; 147 } 148 149 public void setRel(String rel) { 150 this.rel = rel; 151 } 152 153 public void setRev(String rev) { 154 this.rev = rev; 155 } 156 157 public void setShape(String shape) { 158 this.shape = shape; 159 } 160 161 public void setStyle(String style) { 162 this.style = style; 163 } 164 165 public void setStyleClass(String styleClass) { 166 this.styleClass = styleClass; 167 } 168 169 public void setTabindex(String tabindex) { 170 this.tabindex = tabindex; 171 } 172 173 public void setTarget(String target) { 174 this.target = target; 175 } 176 177 public void setTitle(String title) { 178 this.title = title; 179 } 180 181 public void setType(String type) { 182 this.type = type; 183 } 184 185 public String getRendererType() { 186 return "javax.faces.Link"; 187 } 188 189 public String getComponentType() { 190 return "javax.faces.HtmlCommandLink"; 191 } 192 193 194 protected void setProperties(UIComponent component) { 195 super.setProperties(component); 196 197 UICommand command; 198 try { 199 command = (UICommand) component; 200 } catch (ClassCastException cce) { 201 throw new FacesException("Tag <" + getClass().getName() + "> expected UICommand. " + 202 "Got <" + component.getClass().getName() + ">"); 203 } 204 205 if (action != null) { 206 MethodBinding vb; 207 if (FacesUtils.isExpression(action)) { 208 vb = getApplication().createMethodBinding(action, null); 209 } else { 210 vb = new ConstantMethodBinding(action); 211 } 212 command.setAction(vb); 213 } 214 215 if (actionListener != null) { 216 if (FacesUtils.isExpression(actionListener)) { 217 MethodBinding vb = getApplication().createMethodBinding(actionListener, 218 new Class []{ ActionEvent.class }); 219 command.setActionListener(vb); 220 } else { 221 throw new FacesException("Tag <" + getClass().getName() + "> actionListener must be an expression. " + 222 "Got <" + actionListener + ">"); 223 } 224 } 225 226 if (immediate != null) { 227 if (FacesUtils.isExpression(immediate)) { 228 command.setValueBinding("immediate", createValueBinding(immediate)); 229 } else { 230 command.setImmediate(BooleanUtils.toBoolean(immediate)); 231 } 232 } 233 234 if (value != null) { 235 if (FacesUtils.isExpression(value)) { 236 command.setValueBinding("value", createValueBinding(value)); 237 } else { 238 command.setValue(value); 239 } 240 } 241 242 setProperty(component, "accesskey", accesskey); 243 setProperty(component, "charset", charset); 244 setProperty(component, "coords", coords); 245 setProperty(component, "dir", dir); 246 setProperty(component, "hreflang", hreflang); 247 setProperty(component, "lang", lang); 248 setProperty(component, "onblur", onblur); 249 setProperty(component, "ondblclick", ondblclick); 250 setProperty(component, "onfocus", onfocus); 251 setProperty(component, "onkeydown", onkeydown); 252 setProperty(component, "onkeypress", onkeypress); 253 setProperty(component, "onkeyup", onkeyup); 254 setProperty(component, "onmousedown", onmousedown); 255 setProperty(component, "onmousemove", onmousemove); 256 setProperty(component, "onmouseout", onmouseout); 257 setProperty(component, "onmouseover", onmouseover); 258 setProperty(component, "onmouseup", onmouseup); 259 setProperty(component, "rel", rel); 260 setProperty(component, "rev", rev); 261 setProperty(component, "shape", shape); 262 setProperty(component, "style", style); 263 setProperty(component, "styleClass", styleClass); 264 setProperty(component, "tabindex", tabindex); 265 setProperty(component, "target", target); 266 setProperty(component, "title", title); 267 setProperty(component, "type", type); 268 } 269 270 public void recycle() { 271 super.recycle(); 272 action = null; 273 actionListener = null; 274 immediate = null; 275 value = null; 276 accesskey = null; 277 charset = null; 278 coords = null; 279 dir = null; 280 hreflang = null; 281 lang = null; 282 onblur = null; 283 ondblclick = null; 284 onfocus = null; 285 onkeydown = null; 286 onkeypress = null; 287 onkeyup = null; 288 onmousedown = null; 289 onmousemove = null; 290 onmouseout = null; 291 onmouseover = null; 292 onmouseup = null; 293 rel = null; 294 rev = null; 295 shape = null; 296 style = null; 297 styleClass = null; 298 tabindex = null; 299 target = null; 300 title = null; 301 type = null; 302 } 303 } 304 | Popular Tags |