2
* Copyright 2002-2004 The Apache Software Foundation.
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
17
package org.apache.struts.faces.taglib;
20
import javax.faces.component.ActionSource;
21
import javax.faces.component.UIComponent;
22
import javax.faces.context.FacesContext;
23
import javax.faces.el.MethodBinding;
27
* <p>Render a <code>CommandLinkComponent</code> inside a
28
* Struts-Faces <code>FormComponent</code>.</p>
30
* @version $Rev: 54934 $ $Date: 2004-10-16 18:07:50 +0100 (Sat, 16 Oct 2004) $
33
public class CommandLinkTag extends AbstractFacesTag {
36
// ------------------------------------------------------ Instance Variables
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;
68
// ---------------------------------------------------------- Tag Attributes
71
public void setAccesskey(String accesskey) {
72
this.accesskey = accesskey;
76
public void setAction(String action) {
81
public void setCharset(String charset) {
82
this.charset = charset;
86
public void setDir(String dir) {
91
public void setHreflang(String hreflang) {
92
this.hreflang = hreflang;
96
public void setImmediate(String immediate) {
97
this.immediate = immediate;
101
public void setLang(String lang) {
106
public void setOnblur(String onblur) {
107
this.onblur = onblur;
111
public void setOnclick(String onclick) {
112
this.onclick = onclick;
116
public void setOndblclick(String ondblclick) {
117
this.ondblclick = ondblclick;
121
public void setOnfocus(String onfocus) {
122
this.onfocus = onfocus;
126
public void setOnkeydown(String onkeydown) {
127
this.onkeydown = onkeydown;
131
public void setOnkeypress(String onkeypress) {
132
this.onkeypress = onkeypress;
136
public void setOnkeyup(String onkeyup) {
137
this.onkeyup = onkeyup;
141
public void setOnmousedown(String onmousedown) {
142
this.onmousedown = onmousedown;
146
public void setOnmousemove(String onmousemove) {
147
this.onmousemove = onmousemove;
151
public void setOnmouseout(String onmouseout) {
152
this.onmouseout = onmouseout;
156
public void setOnmouseover(String onmouseover) {
157
this.onmouseover = onmouseover;
161
public void setOnmouseup(String onmouseup) {
162
this.onmouseup = onmouseup;
166
public void setRel(String rel) {
171
public void setRev(String rev) {
176
public void setStyle(String style) {
181
public void setStyleClass(String styleClass) {
182
this.styleClass = styleClass;
186
public void setTabindex(String tabindex) {
187
this.tabindex = tabindex;
191
public void setTarget(String target) {
192
this.target = target;
196
public void setTitle(String title) {
201
public void setType(String type) {
206
// ------------------------------------------------------------- Tag Methods
210
* <p>Release any allocated resources.</p>
212
public void release() {
246
// ---------------------------------------------------------- Public Methods
250
* <p>Return the type of component to be created for this tag.</p>
252
public String getComponentType() {
254
return ("org.apache.struts.faces.CommandLink");
260
* <p>Return the <code>rendererType</code> to be used for rendering
263
public String getRendererType() {
265
return ("org.apache.struts.faces.CommandLink");
270
// ------------------------------------------------------- Protected Methods
274
* <p>Override attributes set on this tag instance.</p>
276
* @param component Component whose attributes should be overridden
278
protected void setProperties(UIComponent component) {
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);
287
final String outcome = action;
288
MethodBinding mb = new ConstantMethodBinding(outcome);
289
((ActionSource) component).setAction(mb);
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);
325
// Private MethodBinding Implementation To Return A Constant Value
327
class ConstantMethodBinding extends MethodBinding {
329
public ConstantMethodBinding(String outcome) {
330
this.outcome = outcome;
333
private String outcome = null;
335
public Object invoke(FacesContext context, Object params[]) {
336
return (this.outcome);
339
public Class getType(FacesContext context) {
340
return (String.class);