1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.myfaces.tobago.internal.taglib;
21
22 import javax.faces.application.Application;
23 import javax.faces.component.UIComponent;
24 import javax.faces.context.FacesContext;
25 import org.apache.commons.lang.StringUtils;
26 import org.apache.myfaces.tobago.component.UIButton;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
29
30
31
32
33
34 public final class ButtonTag extends TobagoELTag {
35 private static final Logger LOG = LoggerFactory.getLogger(ButtonTag.class);
36 private javax.el.MethodExpression actionListener;
37 private javax.el.ValueExpression accessKey;
38 private javax.el.ValueExpression markup;
39 private javax.el.ValueExpression labelWithAccessKey;
40 private javax.el.ValueExpression link;
41 private javax.el.ValueExpression defaultCommand;
42 private javax.el.ValueExpression tabIndex;
43 private javax.el.ValueExpression tip;
44 private javax.el.ValueExpression inline;
45 private javax.el.MethodExpression action;
46 private javax.el.ValueExpression jsfResource;
47 private javax.el.ValueExpression resource;
48 private javax.el.ValueExpression transition;
49 private javax.el.ValueExpression image;
50 private javax.el.ValueExpression label;
51 private javax.el.ValueExpression immediate;
52 private javax.el.ValueExpression renderedPartially;
53 private javax.el.ValueExpression target;
54 private javax.el.ValueExpression onclick;
55 private javax.el.ValueExpression disabled;
56
57 @Override
58 public String getComponentType() {
59 return UIButton.COMPONENT_TYPE;
60 }
61 @Override
62 public String getRendererType() {
63 return "Button";
64 }
65
66 @Override
67 protected void setProperties(final UIComponent uiComponent) {
68 super.setProperties(uiComponent);
69 final UIButton component = (UIButton) uiComponent;
70 final FacesContext context = FacesContext.getCurrentInstance();
71 final Application application = context.getApplication();
72 if (actionListener != null) {
73 component.addActionListener(new javax.faces.event.MethodExpressionActionListener(actionListener));
74 }
75 if (accessKey != null) {
76 if (!accessKey.isLiteralText()) {
77 component.setValueExpression("accessKey", accessKey);
78 } else {
79 component.setAccessKey(accessKey.getExpressionString().charAt(0));
80 }
81 }
82 if (markup != null) {
83 if (!markup.isLiteralText()) {
84 component.setValueExpression("markup", markup);
85 } else {
86 component.setMarkup(org.apache.myfaces.tobago.context.Markup.valueOf(markup.getExpressionString()));
87 }
88 }
89 if (labelWithAccessKey != null) {
90 component.setValueExpression("labelWithAccessKey", labelWithAccessKey);
91 }
92
93 if (link != null) {
94 component.setValueExpression("link", link);
95 }
96
97 if (defaultCommand != null) {
98 if (!defaultCommand.isLiteralText()) {
99 component.setValueExpression("defaultCommand", defaultCommand);
100 } else {
101 component.setDefaultCommand(Boolean.parseBoolean(defaultCommand.getExpressionString()));
102 }
103 }
104 if (tabIndex != null) {
105 if (!tabIndex.isLiteralText()) {
106 component.setValueExpression("tabIndex", tabIndex);
107 } else {
108 component.setTabIndex(Integer.parseInt(tabIndex.getExpressionString()));
109 }
110 }
111 if (tip != null) {
112 component.setValueExpression("tip", tip);
113 }
114
115 if (inline != null) {
116 if (!inline.isLiteralText()) {
117 component.setValueExpression("inline", inline);
118 } else {
119 component.setInline(Boolean.parseBoolean(inline.getExpressionString()));
120 }
121 }
122 if (action != null) {
123 component.setActionExpression(action);
124 }
125 if (jsfResource != null) {
126 if (!jsfResource.isLiteralText()) {
127 component.setValueExpression("jsfResource", jsfResource);
128 } else {
129 component.setJsfResource(Boolean.parseBoolean(jsfResource.getExpressionString()));
130 }
131 }
132 if (resource != null) {
133 component.setValueExpression("resource", resource);
134 }
135
136 if (transition != null) {
137 if (!transition.isLiteralText()) {
138 component.setValueExpression("transition", transition);
139 } else {
140 component.setTransition(Boolean.parseBoolean(transition.getExpressionString()));
141 }
142 }
143 if (image != null) {
144 component.setValueExpression("image", image);
145 }
146
147 if (label != null) {
148 component.setValueExpression("label", label);
149 }
150
151 if (immediate != null) {
152 if (!immediate.isLiteralText()) {
153 component.setValueExpression("immediate", immediate);
154 } else {
155 component.setImmediate(Boolean.parseBoolean(immediate.getExpressionString()));
156 }
157 }
158 if (renderedPartially != null) {
159 if (!renderedPartially.isLiteralText()) {
160 component.setValueExpression("renderedPartially", renderedPartially);
161 } else {
162 component.setRenderedPartially(splitList(renderedPartially.getExpressionString()));
163 }
164 }
165 if (target != null) {
166 component.setValueExpression("target", target);
167 }
168
169 if (onclick != null) {
170 component.setValueExpression("onclick", onclick);
171 }
172
173 if (disabled != null) {
174 if (!disabled.isLiteralText()) {
175 component.setValueExpression("disabled", disabled);
176 } else {
177 component.setDisabled(Boolean.parseBoolean(disabled.getExpressionString()));
178 }
179 }
180 }
181
182 public javax.el.MethodExpression getActionListener() {
183 return actionListener;
184 }
185
186 public void setActionListener(final javax.el.MethodExpression actionListener) {
187 this.actionListener = actionListener;
188 }
189
190 public javax.el.ValueExpression getAccessKey() {
191 return accessKey;
192 }
193
194 public void setAccessKey(final javax.el.ValueExpression accessKey) {
195 this.accessKey = accessKey;
196 }
197
198 public javax.el.ValueExpression getMarkup() {
199 return markup;
200 }
201
202 public void setMarkup(final javax.el.ValueExpression markup) {
203 this.markup = markup;
204 }
205
206 public javax.el.ValueExpression getLabelWithAccessKey() {
207 return labelWithAccessKey;
208 }
209
210 public void setLabelWithAccessKey(final javax.el.ValueExpression labelWithAccessKey) {
211 this.labelWithAccessKey = labelWithAccessKey;
212 }
213
214 public javax.el.ValueExpression getLink() {
215 return link;
216 }
217
218 public void setLink(final javax.el.ValueExpression link) {
219 this.link = link;
220 }
221
222 public javax.el.ValueExpression getDefaultCommand() {
223 return defaultCommand;
224 }
225
226 public void setDefaultCommand(final javax.el.ValueExpression defaultCommand) {
227 this.defaultCommand = defaultCommand;
228 }
229
230 public javax.el.ValueExpression getTabIndex() {
231 return tabIndex;
232 }
233
234 public void setTabIndex(final javax.el.ValueExpression tabIndex) {
235 this.tabIndex = tabIndex;
236 }
237
238 public javax.el.ValueExpression getTip() {
239 return tip;
240 }
241
242 public void setTip(final javax.el.ValueExpression tip) {
243 this.tip = tip;
244 }
245
246 public javax.el.ValueExpression getInline() {
247 return inline;
248 }
249
250 public void setInline(final javax.el.ValueExpression inline) {
251 this.inline = inline;
252 }
253
254 public javax.el.MethodExpression getAction() {
255 return action;
256 }
257
258 public void setAction(final javax.el.MethodExpression action) {
259 this.action = action;
260 }
261
262 public javax.el.ValueExpression getJsfResource() {
263 return jsfResource;
264 }
265
266 public void setJsfResource(final javax.el.ValueExpression jsfResource) {
267 this.jsfResource = jsfResource;
268 }
269
270 public javax.el.ValueExpression getResource() {
271 return resource;
272 }
273
274 public void setResource(final javax.el.ValueExpression resource) {
275 this.resource = resource;
276 }
277
278 public javax.el.ValueExpression getTransition() {
279 return transition;
280 }
281
282 public void setTransition(final javax.el.ValueExpression transition) {
283 this.transition = transition;
284 }
285
286 public javax.el.ValueExpression getImage() {
287 return image;
288 }
289
290 public void setImage(final javax.el.ValueExpression image) {
291 this.image = image;
292 }
293
294 public javax.el.ValueExpression getLabel() {
295 return label;
296 }
297
298 public void setLabel(final javax.el.ValueExpression label) {
299 this.label = label;
300 }
301
302 public javax.el.ValueExpression getImmediate() {
303 return immediate;
304 }
305
306 public void setImmediate(final javax.el.ValueExpression immediate) {
307 this.immediate = immediate;
308 }
309
310 public javax.el.ValueExpression getRenderedPartially() {
311 return renderedPartially;
312 }
313
314 public void setRenderedPartially(final javax.el.ValueExpression renderedPartially) {
315 this.renderedPartially = renderedPartially;
316 }
317
318 public javax.el.ValueExpression getTarget() {
319 return target;
320 }
321
322 public void setTarget(final javax.el.ValueExpression target) {
323 this.target = target;
324 }
325
326 public javax.el.ValueExpression getOnclick() {
327 return onclick;
328 }
329
330 public void setOnclick(final javax.el.ValueExpression onclick) {
331 this.onclick = onclick;
332 }
333
334 public javax.el.ValueExpression getDisabled() {
335 return disabled;
336 }
337
338 public void setDisabled(final javax.el.ValueExpression disabled) {
339 this.disabled = disabled;
340 }
341
342
343
344 @Override
345 public void release() {
346 super.release();
347 actionListener = null;
348 accessKey = null;
349 markup = null;
350 labelWithAccessKey = null;
351 link = null;
352 defaultCommand = null;
353 tabIndex = null;
354 tip = null;
355 inline = null;
356 action = null;
357 jsfResource = null;
358 resource = null;
359 transition = null;
360 image = null;
361 label = null;
362 immediate = null;
363 renderedPartially = null;
364 target = null;
365 onclick = null;
366 disabled = null;
367 }
368 }