1 16 17 package org.apache.struts.faces.taglib; 18 19 20 import javax.faces.component.ActionSource; 21 import javax.faces.component.UIComponent; 22 import javax.faces.context.FacesContext; 23 import javax.faces.el.MethodBinding; 24 25 26 32 33 public class CommandLinkTag extends AbstractFacesTag { 34 35 36 38 39 private String accesskey = null; 40 private String action = null; 41 private String charset = null; 42 private String dir = null; 43 private String hreflang = null; 44 private String immediate = null; 45 private String lang = null; 46 private String onblur = null; 47 private String onclick = null; 48 private String ondblclick = null; 49 private String onfocus = null; 50 private String onkeydown = null; 51 private String onkeypress = null; 52 private String onkeyup = null; 53 private String onmousedown = null; 54 private String onmousemove = null; 55 private String onmouseout = null; 56 private String onmouseover = null; 57 private String onmouseup = null; 58 private String rel = null; 59 private String rev = null; 60 private String style = null; 61 private String styleClass = null; 62 private String tabindex = null; 63 private String target = null; 64 private String title = null; 65 private String type = null; 66 67 68 70 71 public void setAccesskey(String accesskey) { 72 this.accesskey = accesskey; 73 } 74 75 76 public void setAction(String action) { 77 this.action = action; 78 } 79 80 81 public void setCharset(String charset) { 82 this.charset = charset; 83 } 84 85 86 public void setDir(String dir) { 87 this.dir = dir; 88 } 89 90 91 public void setHreflang(String hreflang) { 92 this.hreflang = hreflang; 93 } 94 95 96 public void setImmediate(String immediate) { 97 this.immediate = immediate; 98 } 99 100 101 public void setLang(String lang) { 102 this.lang = lang; 103 } 104 105 106 public void setOnblur(String onblur) { 107 this.onblur = onblur; 108 } 109 110 111 public void setOnclick(String onclick) { 112 this.onclick = onclick; 113 } 114 115 116 public void setOndblclick(String ondblclick) { 117 this.ondblclick = ondblclick; 118 } 119 120 121 public void setOnfocus(String onfocus) { 122 this.onfocus = onfocus; 123 } 124 125 126 public void setOnkeydown(String onkeydown) { 127 this.onkeydown = onkeydown; 128 } 129 130 131 public void setOnkeypress(String onkeypress) { 132 this.onkeypress = onkeypress; 133 } 134 135 136 public void setOnkeyup(String onkeyup) { 137 this.onkeyup = onkeyup; 138 } 139 140 141 public void setOnmousedown(String onmousedown) { 142 this.onmousedown = onmousedown; 143 } 144 145 146 public void setOnmousemove(String onmousemove) { 147 this.onmousemove = onmousemove; 148 } 149 150 151 public void setOnmouseout(String onmouseout) { 152 this.onmouseout = onmouseout; 153 } 154 155 156 public void setOnmouseover(String onmouseover) { 157 this.onmouseover = onmouseover; 158 } 159 160 161 public void setOnmouseup(String onmouseup) { 162 this.onmouseup = onmouseup; 163 } 164 165 166 public void setRel(String rel) { 167 this.rel = rel; 168 } 169 170 171 public void setRev(String rev) { 172 this.rev = rev; 173 } 174 175 176 public void setStyle(String style) { 177 this.style = style; 178 } 179 180 181 public void setStyleClass(String styleClass) { 182 this.styleClass = styleClass; 183 } 184 185 186 public void setTabindex(String tabindex) { 187 this.tabindex = tabindex; 188 } 189 190 191 public void setTarget(String target) { 192 this.target = target; 193 } 194 195 196 public void setTitle(String title) { 197 this.title = title; 198 } 199 200 201 public void setType(String type) { 202 this.type = type; 203 } 204 205 206 208 209 212 public void release() { 213 214 super.release(); 215 accesskey = null; 216 action = null; 217 charset = null; 218 dir = null; 219 hreflang = null; 220 immediate = null; 221 lang = null; 222 onblur = null; 223 onclick = null; 224 ondblclick = null; 225 onfocus = null; 226 onkeydown = null; 227 onkeypress = null; 228 onkeyup = null; 229 onmousedown = null; 230 onmousemove = null; 231 onmouseout = null; 232 onmouseover = null; 233 onmouseup = null; 234 rel = null; 235 rev = null; 236 style = null; 237 styleClass = null; 238 tabindex = null; 239 target = null; 240 title = null; 241 type = null; 242 243 } 244 245 246 248 249 252 public String getComponentType() { 253 254 return ("org.apache.struts.faces.CommandLink"); 255 256 } 257 258 259 263 public String getRendererType() { 264 265 return ("org.apache.struts.faces.CommandLink"); 266 267 } 268 269 270 272 273 278 protected void setProperties(UIComponent component) { 279 280 super.setProperties(component); 281 if (action != null) { 282 if (isValueReference(action)) { 283 MethodBinding mb = FacesContext.getCurrentInstance(). 284 getApplication().createMethodBinding(action, null); 285 ((ActionSource) component).setAction(mb); 286 } else { 287 final String outcome = action; 288 MethodBinding mb = new ConstantMethodBinding(outcome); 289 ((ActionSource) component).setAction(mb); 290 } 291 } 292 setStringAttribute(component, "accesskey", accesskey); 293 setStringAttribute(component, "charset", charset); 294 setStringAttribute(component, "dir", dir); 295 setStringAttribute(component, "hreflang", hreflang); 296 setBooleanAttribute(component, "immediate", immediate); 297 setStringAttribute(component, "lang", lang); 298 setStringAttribute(component, "onblur", onblur); 299 setStringAttribute(component, "onclick", onclick); 300 setStringAttribute(component, "ondblclick", ondblclick); 301 setStringAttribute(component, "onfocus", onfocus); 302 setStringAttribute(component, "onkeydown", onkeydown); 303 setStringAttribute(component, "onkeypress", onkeypress); 304 setStringAttribute(component, "onkeyup", onkeyup); 305 setStringAttribute(component, "onmousedown", onmousedown); 306 setStringAttribute(component, "onmousemove", onmousemove); 307 setStringAttribute(component, "onmouseout", onmouseout); 308 setStringAttribute(component, "onmouseover", onmouseover); 309 setStringAttribute(component, "onmouseup", onmouseup); 310 setStringAttribute(component, "rel", rel); 311 setStringAttribute(component, "rev", rev); 312 setStringAttribute(component, "style", style); 313 setStringAttribute(component, "styleClass", styleClass); 314 setStringAttribute(component, "tabindex", tabindex); 315 setStringAttribute(component, "target", target); 316 setStringAttribute(component, "title", title); 317 setStringAttribute(component, "type", type); 318 319 } 320 321 322 } 323 324 325 327 class ConstantMethodBinding extends MethodBinding { 328 329 public ConstantMethodBinding(String outcome) { 330 this.outcome = outcome; 331 } 332 333 private String outcome = null; 334 335 public Object invoke(FacesContext context, Object params[]) { 336 return (this.outcome); 337 } 338 339 public Class getType(FacesContext context) { 340 return (String .class); 341 } 342 343 344 } 345 | Popular Tags |