KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > faces > taglib > html > CommandLinkTag


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */

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 /**
29  * @version CVS $Id: CommandLinkTag.java 53732 2004-10-04 18:38:22Z vgritsenko $
30  */

31 public class CommandLinkTag extends UIComponentTag {
32
33     private String JavaDoc action;
34     private String JavaDoc actionListener;
35     private String JavaDoc immediate;
36     private String JavaDoc value;
37     private String JavaDoc accesskey;
38     private String JavaDoc charset;
39     private String JavaDoc coords;
40     private String JavaDoc dir;
41     private String JavaDoc hreflang;
42     private String JavaDoc lang;
43     private String JavaDoc onblur;
44     private String JavaDoc ondblclick;
45     private String JavaDoc onfocus;
46     private String JavaDoc onkeydown;
47     private String JavaDoc onkeypress;
48     private String JavaDoc onkeyup;
49     private String JavaDoc onmousedown;
50     private String JavaDoc onmousemove;
51     private String JavaDoc onmouseout;
52     private String JavaDoc onmouseover;
53     private String JavaDoc onmouseup;
54     private String JavaDoc rel;
55     private String JavaDoc rev;
56     private String JavaDoc shape;
57     private String JavaDoc style;
58     private String JavaDoc styleClass;
59     private String JavaDoc tabindex;
60     private String JavaDoc target;
61     private String JavaDoc title;
62     private String JavaDoc type;
63
64
65     public void setAction(String JavaDoc action) {
66         this.action = action;
67     }
68
69     public void setActionListener(String JavaDoc actionListener) {
70         this.actionListener = actionListener;
71     }
72
73     public void setImmediate(String JavaDoc immediate) {
74         this.immediate = immediate;
75     }
76
77     public void setValue(String JavaDoc value) {
78         this.value = value;
79     }
80
81     public void setAccesskey(String JavaDoc accesskey) {
82         this.accesskey = accesskey;
83     }
84
85     public void setCharset(String JavaDoc charset) {
86         this.charset = charset;
87     }
88
89     public void setCoords(String JavaDoc coords) {
90         this.coords = coords;
91     }
92
93     public void setDir(String JavaDoc dir) {
94         this.dir = dir;
95     }
96
97     public void setHreflang(String JavaDoc hreflang) {
98         this.hreflang = hreflang;
99     }
100
101     public void setLang(String JavaDoc lang) {
102         this.lang = lang;
103     }
104
105     public void setOnblur(String JavaDoc onblur) {
106         this.onblur = onblur;
107     }
108
109     public void setOndblclick(String JavaDoc ondblclick) {
110         this.ondblclick = ondblclick;
111     }
112
113     public void setOnfocus(String JavaDoc onfocus) {
114         this.onfocus = onfocus;
115     }
116
117     public void setOnkeydown(String JavaDoc onkeydown) {
118         this.onkeydown = onkeydown;
119     }
120
121     public void setOnkeypress(String JavaDoc onkeypress) {
122         this.onkeypress = onkeypress;
123     }
124
125     public void setOnkeyup(String JavaDoc onkeyup) {
126         this.onkeyup = onkeyup;
127     }
128
129     public void setOnmousedown(String JavaDoc onmousedown) {
130         this.onmousedown = onmousedown;
131     }
132
133     public void setOnmousemove(String JavaDoc onmousemove) {
134         this.onmousemove = onmousemove;
135     }
136
137     public void setOnmouseout(String JavaDoc onmouseout) {
138         this.onmouseout = onmouseout;
139     }
140
141     public void setOnmouseover(String JavaDoc onmouseover) {
142         this.onmouseover = onmouseover;
143     }
144
145     public void setOnmouseup(String JavaDoc onmouseup) {
146         this.onmouseup = onmouseup;
147     }
148
149     public void setRel(String JavaDoc rel) {
150         this.rel = rel;
151     }
152
153     public void setRev(String JavaDoc rev) {
154         this.rev = rev;
155     }
156
157     public void setShape(String JavaDoc shape) {
158         this.shape = shape;
159     }
160
161     public void setStyle(String JavaDoc style) {
162         this.style = style;
163     }
164
165     public void setStyleClass(String JavaDoc styleClass) {
166         this.styleClass = styleClass;
167     }
168
169     public void setTabindex(String JavaDoc tabindex) {
170         this.tabindex = tabindex;
171     }
172
173     public void setTarget(String JavaDoc target) {
174         this.target = target;
175     }
176
177     public void setTitle(String JavaDoc title) {
178         this.title = title;
179     }
180
181     public void setType(String JavaDoc type) {
182         this.type = type;
183     }
184
185     public String JavaDoc getRendererType() {
186         return "javax.faces.Link";
187     }
188
189     public String JavaDoc 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 JavaDoc 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 JavaDoc[]{ 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