Source code: renderkits/taglib/xul/CommandButtonTag.java
1 /*
2 * The contents of this file are subject to the terms
3 * of the Common Development and Distribution License
4 * (the License). You may not use this file except in
5 * compliance with the License.
6 *
7 * You can obtain a copy of the License at
8 * https://javaserverfaces.dev.java.net/CDDL.html or
9 * legal/CDDLv1.0.txt.
10 * See the License for the specific language governing
11 * permission and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL
14 * Header Notice in each file and include the License file
15 * at legal/CDDLv1.0.txt.
16 * If applicable, add the following below the CDDL Header,
17 * with the fields enclosed by brackets [] replaced by
18 * your own identifying information:
19 * "Portions Copyrighted [year] [name of copyright owner]"
20 *
21 * [Name of File] [ver.__] [Date]
22 *
23 * Copyright 2005 Sun Microsystems Inc. All Rights Reserved
24 */
25
26 package renderkits.taglib.xul;
27
28 import javax.faces.component.UIComponent;
29 import javax.faces.event.MethodExpressionActionListener;
30 import javax.faces.webapp.UIComponentELTag;
31 import javax.servlet.jsp.JspException;
32
33
34 public final class CommandButtonTag extends UIComponentELTag {
35
36
37 // Setter Methods
38 // PROPERTY: action
39 private javax.el.MethodExpression action;
40
41 public void setAction(javax.el.MethodExpression action) {
42 this.action = action;
43 }
44
45 // PROPERTY: actionListener
46 private javax.el.MethodExpression actionListener;
47
48 public void setActionListener(javax.el.MethodExpression actionListener) {
49 this.actionListener = actionListener;
50 }
51
52 // PROPERTY: immediate
53 private javax.el.ValueExpression immediate;
54
55 public void setImmediate(javax.el.ValueExpression immediate) {
56 this.immediate = immediate;
57 }
58
59 // PROPERTY: label
60 private javax.el.ValueExpression label;
61
62 public void setLabel(javax.el.ValueExpression label) {
63 this.label = label;
64 }
65
66 // PROPERTY: onclick
67 private javax.el.ValueExpression onclick;
68
69 public void setOnclick(javax.el.ValueExpression onclick) {
70 this.onclick = onclick;
71 }
72
73 // PROPERTY: oncommand
74 private javax.el.ValueExpression oncommand;
75
76 public void setOnactivate(javax.el.ValueExpression oncommand) {
77 this.oncommand = oncommand;
78 }
79
80 // PROPERTY: onfocusin
81 private javax.el.ValueExpression onfocusin;
82
83 public void setOnfocusin(javax.el.ValueExpression onfocusin) {
84 this.onfocusin = onfocusin;
85 }
86
87 // PROPERTY: onfocusout
88 private javax.el.ValueExpression onfocusout;
89
90 public void setOnfocusout(javax.el.ValueExpression onfocusout) {
91 this.onfocusout = onfocusout;
92 }
93
94 // PROPERTY: onmousedown
95 private javax.el.ValueExpression onmousedown;
96
97 public void setOnmousedown(javax.el.ValueExpression onmousedown) {
98 this.onmousedown = onmousedown;
99 }
100
101 // PROPERTY: onmousemove
102 private javax.el.ValueExpression onmousemove;
103
104 public void setOnmousemove(javax.el.ValueExpression onmousemove) {
105 this.onmousemove = onmousemove;
106 }
107
108 // PROPERTY: onmouseout
109 private javax.el.ValueExpression onmouseout;
110
111 public void setOnmouseout(javax.el.ValueExpression onmouseout) {
112 this.onmouseout = onmouseout;
113 }
114
115 // PROPERTY: onmouseover
116 private javax.el.ValueExpression onmouseover;
117
118 public void setOnmouseover(javax.el.ValueExpression onmouseover) {
119 this.onmouseover = onmouseover;
120 }
121
122 // PROPERTY: onmouseup
123 private javax.el.ValueExpression onmouseup;
124
125 public void setOnmouseup(javax.el.ValueExpression onmouseup) {
126 this.onmouseup = onmouseup;
127 }
128
129 // PROPERTY: style
130 private javax.el.ValueExpression style;
131
132 public void setStyle(javax.el.ValueExpression style) {
133 this.style = style;
134 }
135
136 // PROPERTY: styleClass
137 private javax.el.ValueExpression styleClass;
138
139 public void setStyleClass(javax.el.ValueExpression styleClass) {
140 this.styleClass = styleClass;
141 }
142
143 // PROPERTY: type
144 private javax.el.ValueExpression type;
145
146 public void setType(javax.el.ValueExpression type) {
147 this.type = type;
148 }
149
150 // PROPERTY: value
151 private javax.el.ValueExpression value;
152
153 public void setValue(javax.el.ValueExpression value) {
154 this.value = value;
155 }
156
157 // General Methods
158 public String getRendererType() {
159 return "renderkit.xul.Button";
160 }
161
162 public String getComponentType() {
163 return "javax.faces.Command";
164 }
165
166 protected void setProperties(UIComponent component) {
167 super.setProperties(component);
168 javax.faces.component.UICommand command = null;
169 try {
170 command = (javax.faces.component.UICommand) component;
171 } catch (ClassCastException cce) {
172 throw new IllegalStateException("Component "
173 + component.toString()
174 + " not expected type. Expected: javax.faces.component.UICommand. Perhaps you're missing a tag?");
175 }
176
177 if (action != null) {
178 command.setActionExpression(action);
179 }
180 if (actionListener != null) {
181 command.addActionListener(new MethodExpressionActionListener(
182 actionListener));
183 }
184 if (immediate != null) {
185 if (!immediate.isLiteralText()) {
186 command.setValueExpression("immediate", immediate);
187 } else {
188 command.setImmediate(java.lang.Boolean
189 .valueOf(immediate.getExpressionString()).booleanValue());
190 }
191 }
192 if (label != null) {
193 if (!label.isLiteralText()) {
194 command.setValueExpression("label", label);
195 } else {
196 command.getAttributes()
197 .put("label", label.getExpressionString());
198 }
199 }
200 if (oncommand != null) {
201 if (!oncommand.isLiteralText()) {
202 command.setValueExpression("oncommand", oncommand);
203 } else {
204 command.getAttributes()
205 .put("oncommand", oncommand.getExpressionString());
206 }
207 }
208 if (onclick != null) {
209 if (!onclick.isLiteralText()) {
210 command.setValueExpression("onclick", onclick);
211 } else {
212 command.getAttributes()
213 .put("onclick", onclick.getExpressionString());
214 }
215 }
216 if (onfocusin != null) {
217 if (!onfocusin.isLiteralText()) {
218 command.setValueExpression("onfocusin", onfocusin);
219 } else {
220 command.getAttributes()
221 .put("onfocusin", onfocusin.getExpressionString());
222 }
223 }
224 if (onfocusout != null) {
225 if (!onfocusout.isLiteralText()) {
226 command.setValueExpression("onfocusout", onfocusout);
227 } else {
228 command.getAttributes()
229 .put("onfocusout", onfocusout.getExpressionString());
230 }
231 }
232 if (onmousedown != null) {
233 if (!onmousedown.isLiteralText()) {
234 command.setValueExpression("onmousedown", onmousedown);
235 } else {
236 command.getAttributes()
237 .put("onmousedown", onmousedown.getExpressionString());
238 }
239 }
240 if (onmousemove != null) {
241 if (!onmousemove.isLiteralText()) {
242 command.setValueExpression("onmousemove", onmousemove);
243 } else {
244 command.getAttributes()
245 .put("onmousemove", onmousemove.getExpressionString());
246 }
247 }
248 if (onmouseout != null) {
249 if (!onmouseout.isLiteralText()) {
250 command.setValueExpression("onmouseout", onmouseout);
251 } else {
252 command.getAttributes()
253 .put("onmouseout", onmouseout.getExpressionString());
254 }
255 }
256 if (onmouseover != null) {
257 if (!onmouseover.isLiteralText()) {
258 command.setValueExpression("onmouseover", onmouseover);
259 } else {
260 command.getAttributes()
261 .put("onmouseover", onmouseover.getExpressionString());
262 }
263 }
264 if (onmouseup != null) {
265 if (!onmouseup.isLiteralText()) {
266 command.setValueExpression("onmouseup", onmouseup);
267 } else {
268 command.getAttributes()
269 .put("onmouseup", onmouseup.getExpressionString());
270 }
271 }
272 if (style != null) {
273 if (!style.isLiteralText()) {
274 command.setValueExpression("style", style);
275 } else {
276 command.getAttributes()
277 .put("style", style.getExpressionString());
278 }
279 }
280 if (styleClass != null) {
281 if (!styleClass.isLiteralText()) {
282 command.setValueExpression("styleClass", styleClass);
283 } else {
284 command.getAttributes()
285 .put("styleClass", styleClass.getExpressionString());
286 }
287 }
288 if (type != null) {
289 if (!type.isLiteralText()) {
290 command.setValueExpression("type", type);
291 } else {
292 command.getAttributes().put("type", type.getExpressionString());
293 }
294 }
295 if (value != null) {
296 if (!value.isLiteralText()) {
297 command.setValueExpression("value", value);
298 } else {
299 command.setValue(value.getExpressionString());
300 }
301 }
302 }
303
304 // Methods From TagSupport
305 public int doStartTag() throws JspException {
306 try {
307 return super.doStartTag();
308 } catch (Exception e) {
309 Throwable root = e;
310 while (root.getCause() != null) {
311 root = root.getCause();
312 }
313 throw new JspException(root);
314 }
315 }
316
317 public int doEndTag() throws JspException {
318 try {
319 return super.doEndTag();
320 } catch (Exception e) {
321 Throwable root = e;
322 while (root.getCause() != null) {
323 root = root.getCause();
324 }
325 throw new JspException(root);
326 }
327 }
328
329 // RELEASE
330 public void release() {
331 super.release();
332
333 // component properties
334 this.action = null;
335 this.actionListener = null;
336 this.immediate = null;
337 this.value = null;
338
339 // rendered attributes
340 this.label = null;
341 this.onclick = null;
342 this.oncommand = null;
343 this.onfocusin = null;
344 this.onfocusout = null;
345 this.onmousedown = null;
346 this.onmousemove = null;
347 this.onmouseout = null;
348 this.onmouseover = null;
349 this.onmouseup = null;
350 this.style = null;
351 this.styleClass = null;
352 this.type = null;
353 }
354
355 public String getDebugString() {
356 String result =
357 "id: " + this.getId() + " class: " + this.getClass().getName();
358 return result;
359 }
360
361 }