001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.cocoon.faces.taglib.html;
018:
019: import org.apache.cocoon.faces.FacesUtils;
020: import org.apache.cocoon.faces.taglib.UIComponentTag;
021: import org.apache.commons.lang.BooleanUtils;
022:
023: import javax.faces.FacesException;
024: import javax.faces.component.UICommand;
025: import javax.faces.component.UIComponent;
026: import javax.faces.el.MethodBinding;
027: import javax.faces.event.ActionEvent;
028:
029: /**
030: * @version CVS $Id: CommandLinkTag.java 433543 2006-08-22 06:22:54Z crossley $
031: */
032: public class CommandLinkTag extends UIComponentTag {
033:
034: private String action;
035: private String actionListener;
036: private String immediate;
037: private String value;
038: private String accesskey;
039: private String charset;
040: private String coords;
041: private String dir;
042: private String hreflang;
043: private String lang;
044: private String onblur;
045: private String ondblclick;
046: private String onfocus;
047: private String onkeydown;
048: private String onkeypress;
049: private String onkeyup;
050: private String onmousedown;
051: private String onmousemove;
052: private String onmouseout;
053: private String onmouseover;
054: private String onmouseup;
055: private String rel;
056: private String rev;
057: private String shape;
058: private String style;
059: private String styleClass;
060: private String tabindex;
061: private String target;
062: private String title;
063: private String type;
064:
065: public void setAction(String action) {
066: this .action = action;
067: }
068:
069: public void setActionListener(String actionListener) {
070: this .actionListener = actionListener;
071: }
072:
073: public void setImmediate(String immediate) {
074: this .immediate = immediate;
075: }
076:
077: public void setValue(String value) {
078: this .value = value;
079: }
080:
081: public void setAccesskey(String accesskey) {
082: this .accesskey = accesskey;
083: }
084:
085: public void setCharset(String charset) {
086: this .charset = charset;
087: }
088:
089: public void setCoords(String coords) {
090: this .coords = coords;
091: }
092:
093: public void setDir(String dir) {
094: this .dir = dir;
095: }
096:
097: public void setHreflang(String hreflang) {
098: this .hreflang = hreflang;
099: }
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: protected void setProperties(UIComponent component) {
194: super .setProperties(component);
195:
196: UICommand command;
197: try {
198: command = (UICommand) component;
199: } catch (ClassCastException cce) {
200: throw new FacesException("Tag <" + getClass().getName()
201: + "> expected UICommand. " + "Got <"
202: + 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()
218: .createMethodBinding(actionListener,
219: new Class[] { ActionEvent.class });
220: command.setActionListener(vb);
221: } else {
222: throw new FacesException("Tag <" + getClass().getName()
223: + "> actionListener must be an expression. "
224: + "Got <" + actionListener + ">");
225: }
226: }
227:
228: if (immediate != null) {
229: if (FacesUtils.isExpression(immediate)) {
230: command.setValueBinding("immediate",
231: createValueBinding(immediate));
232: } else {
233: command.setImmediate(BooleanUtils.toBoolean(immediate));
234: }
235: }
236:
237: if (value != null) {
238: if (FacesUtils.isExpression(value)) {
239: command.setValueBinding("value",
240: createValueBinding(value));
241: } else {
242: command.setValue(value);
243: }
244: }
245:
246: setProperty(component, "accesskey", accesskey);
247: setProperty(component, "charset", charset);
248: setProperty(component, "coords", coords);
249: setProperty(component, "dir", dir);
250: setProperty(component, "hreflang", hreflang);
251: setProperty(component, "lang", lang);
252: setProperty(component, "onblur", onblur);
253: setProperty(component, "ondblclick", ondblclick);
254: setProperty(component, "onfocus", onfocus);
255: setProperty(component, "onkeydown", onkeydown);
256: setProperty(component, "onkeypress", onkeypress);
257: setProperty(component, "onkeyup", onkeyup);
258: setProperty(component, "onmousedown", onmousedown);
259: setProperty(component, "onmousemove", onmousemove);
260: setProperty(component, "onmouseout", onmouseout);
261: setProperty(component, "onmouseover", onmouseover);
262: setProperty(component, "onmouseup", onmouseup);
263: setProperty(component, "rel", rel);
264: setProperty(component, "rev", rev);
265: setProperty(component, "shape", shape);
266: setProperty(component, "style", style);
267: setProperty(component, "styleClass", styleClass);
268: setProperty(component, "tabindex", tabindex);
269: setProperty(component, "target", target);
270: setProperty(component, "title", title);
271: setProperty(component, "type", type);
272: }
273:
274: public void recycle() {
275: super.recycle();
276: action = null;
277: actionListener = null;
278: immediate = null;
279: value = null;
280: accesskey = null;
281: charset = null;
282: coords = null;
283: dir = null;
284: hreflang = null;
285: lang = null;
286: onblur = null;
287: ondblclick = null;
288: onfocus = null;
289: onkeydown = null;
290: onkeypress = null;
291: onkeyup = null;
292: onmousedown = null;
293: onmousemove = null;
294: onmouseout = null;
295: onmouseover = null;
296: onmouseup = null;
297: rel = null;
298: rev = null;
299: shape = null;
300: style = null;
301: styleClass = null;
302: tabindex = null;
303: target = null;
304: title = null;
305: type = null;
306: }
307: }
|