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.component;
21
22 import javax.faces.context.FacesContext;
23 import org.apache.myfaces.tobago.context.Markup;
24 import org.apache.myfaces.tobago.internal.component.AbstractUICommand;
25 import org.apache.myfaces.tobago.layout.Display;
26 import org.apache.myfaces.tobago.layout.Measure;
27 import org.apache.commons.lang.ArrayUtils;
28 import org.apache.commons.lang.StringUtils;
29 import org.apache.myfaces.tobago.internal.util.Deprecation;
30 import org.apache.myfaces.tobago.renderkit.MarginValues;
31 import org.apache.myfaces.tobago.renderkit.SpacingValues;
32 import org.apache.myfaces.tobago.renderkit.LayoutComponentRenderer;
33 import javax.el.ELException;
34 import javax.faces.FacesException;
35 import java.util.ArrayList;
36 import java.util.List;
37 import javax.el.MethodExpression;
38 import javax.el.ValueExpression;
39
40
41
42
43
44
45 public class UIButton
46 extends AbstractUICommand implements SupportsMarkup {
47
48 public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.Button";
49
50 public static final String COMPONENT_FAMILY = "javax.faces.Command";
51
52 private org.apache.myfaces.tobago.context.Markup currentMarkup;
53
54 enum PropertyKeys {
55 accessKey,
56 markup,
57 marginLeft,
58 labelWithAccessKey,
59 link,
60 defaultCommand,
61 tabIndex,
62 minimumHeight,
63 tip,
64 height,
65 minimumWidth,
66 inline,
67 rowSpan,
68 left,
69 columnSpan,
70 top,
71 maximumHeight,
72 currentWidth,
73 marginTop,
74 width,
75 marginRight,
76 preferredHeight,
77 jsfResource,
78 resource,
79 currentHeight,
80 transition,
81 image,
82 display,
83 label,
84 maximumWidth,
85 preferredWidth,
86 marginBottom,
87 verticalIndex,
88 renderedPartially,
89 target,
90 onclick,
91 horizontalIndex,
92 disabled,
93 }
94
95 public String getFamily() {
96 return COMPONENT_FAMILY;
97 }
98
99
100
101
102
103
104 @Deprecated
105 public java.lang.Character getAccessKey() {
106 Deprecation.LOG.error("The attribute 'accessKey' of 'UIButton' is deprecated. "
107 + "Please refer the documentation for further information.");
108 return (java.lang.Character) getStateHelper().eval(PropertyKeys.accessKey);
109 }
110
111 @Deprecated
112 public void setAccessKey(java.lang.Character accessKey) {
113 getStateHelper().put(PropertyKeys.accessKey, accessKey);
114 }
115
116 public org.apache.myfaces.tobago.context.Markup getMarkup() {
117 Object object = getStateHelper().eval(PropertyKeys.markup);
118 if (object != null) {
119 return Markup.valueOf(object);
120 }
121 return null;
122 }
123
124 public void setMarkup(org.apache.myfaces.tobago.context.Markup markup) {
125 getStateHelper().put(PropertyKeys.markup, markup);
126 }
127
128 public org.apache.myfaces.tobago.layout.Measure getMarginLeft() {
129 Object object = getStateHelper().eval(PropertyKeys.marginLeft);
130 if (object != null) {
131 return Measure.valueOf(object);
132 }
133 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginLeft(getFacesContext(), this);
134 }
135
136 public void setMarginLeft(org.apache.myfaces.tobago.layout.Measure marginLeft) {
137 getStateHelper().put(PropertyKeys.marginLeft, marginLeft);
138 }
139
140
141
142
143
144
145
146 @Deprecated
147 public java.lang.String getLabelWithAccessKey() {
148 Deprecation.LOG.error("The attribute 'labelWithAccessKey' of 'UIButton' is deprecated. "
149 + "Please refer the documentation for further information.");
150 return (java.lang.String) getStateHelper().eval(PropertyKeys.labelWithAccessKey);
151 }
152
153 @Deprecated
154 public void setLabelWithAccessKey(java.lang.String labelWithAccessKey) {
155 getStateHelper().put(PropertyKeys.labelWithAccessKey, labelWithAccessKey);
156 }
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173 public java.lang.String getLink() {
174 return (java.lang.String) getStateHelper().eval(PropertyKeys.link);
175 }
176
177 public void setLink(java.lang.String link) {
178 getStateHelper().put(PropertyKeys.link, link);
179 }
180
181
182
183
184
185
186 public boolean isDefaultCommand() {
187 Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.defaultCommand);
188 if (bool != null) {
189 return bool;
190 }
191 return false;
192 }
193
194 public void setDefaultCommand(boolean defaultCommand) {
195 getStateHelper().put(PropertyKeys.defaultCommand, defaultCommand);
196 }
197
198
199
200
201
202
203
204
205
206
207
208
209 public java.lang.Integer getTabIndex() {
210 Number value = (Number) getStateHelper().eval(PropertyKeys.tabIndex);
211 if (value != null) {
212 return value.intValue();
213 }
214 return null;
215 }
216
217 public void setTabIndex(java.lang.Integer tabIndex) {
218 getStateHelper().put(PropertyKeys.tabIndex, tabIndex);
219 }
220
221 public org.apache.myfaces.tobago.layout.Measure getMinimumHeight() {
222 Object object = getStateHelper().eval(PropertyKeys.minimumHeight);
223 if (object != null) {
224 return Measure.valueOf(object);
225 }
226 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMinimumHeight(getFacesContext(), this);
227 }
228
229 public void setMinimumHeight(org.apache.myfaces.tobago.layout.Measure minimumHeight) {
230 getStateHelper().put(PropertyKeys.minimumHeight, minimumHeight);
231 }
232
233
234
235
236
237 public java.lang.String getTip() {
238 return (java.lang.String) getStateHelper().eval(PropertyKeys.tip);
239 }
240
241 public void setTip(java.lang.String tip) {
242 getStateHelper().put(PropertyKeys.tip, tip);
243 }
244
245
246
247
248
249 public org.apache.myfaces.tobago.layout.Measure getHeight() {
250 Object object = getStateHelper().eval(PropertyKeys.height);
251 if (object != null) {
252 return Measure.valueOf(object);
253 }
254 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getHeight(getFacesContext(), this);
255 }
256
257 public void setHeight(org.apache.myfaces.tobago.layout.Measure height) {
258 getStateHelper().put(PropertyKeys.height, height);
259 }
260
261 public org.apache.myfaces.tobago.layout.Measure getMinimumWidth() {
262 Object object = getStateHelper().eval(PropertyKeys.minimumWidth);
263 if (object != null) {
264 return Measure.valueOf(object);
265 }
266 return ((LayoutComponentRenderer)getRenderer(getFacesContext())).getMinimumWidth(getFacesContext(), this);
267 }
268
269 public void setMinimumWidth(org.apache.myfaces.tobago.layout.Measure minimumWidth) {
270 getStateHelper().put(PropertyKeys.minimumWidth, minimumWidth);
271 }
272
273
274
275
276
277 @Deprecated
278 public boolean isInline() {
279 Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.inline);
280 if (bool != null) {
281 return bool;
282 }
283 return false;
284 }
285
286 @Deprecated
287 public void setInline(boolean inline) {
288 Deprecation.LOG.error("The attribute 'inline' of 'UIButton' is deprecated. "
289 + "Please refer the documentation for further information.");
290 getStateHelper().put(PropertyKeys.inline, inline);
291 }
292
293 public java.lang.Integer getRowSpan() {
294 Number value = (Number) getStateHelper().eval(PropertyKeys.rowSpan);
295 if (value != null) {
296 return value.intValue();
297 }
298 return 1;
299 }
300
301 public void setRowSpan(java.lang.Integer rowSpan) {
302 getStateHelper().put(PropertyKeys.rowSpan, rowSpan);
303 }
304
305
306
307
308
309 public org.apache.myfaces.tobago.layout.Measure getLeft() {
310 Object object = getStateHelper().eval(PropertyKeys.left);
311 if (object != null) {
312 return Measure.valueOf(object);
313 }
314 return null;
315 }
316
317 public void setLeft(org.apache.myfaces.tobago.layout.Measure left) {
318 getStateHelper().put(PropertyKeys.left, left);
319 }
320
321 public java.lang.Integer getColumnSpan() {
322 Number value = (Number) getStateHelper().eval(PropertyKeys.columnSpan);
323 if (value != null) {
324 return value.intValue();
325 }
326 return 1;
327 }
328
329 public void setColumnSpan(java.lang.Integer columnSpan) {
330 getStateHelper().put(PropertyKeys.columnSpan, columnSpan);
331 }
332
333
334
335
336
337 public org.apache.myfaces.tobago.layout.Measure getTop() {
338 Object object = getStateHelper().eval(PropertyKeys.top);
339 if (object != null) {
340 return Measure.valueOf(object);
341 }
342 return null;
343 }
344
345 public void setTop(org.apache.myfaces.tobago.layout.Measure top) {
346 getStateHelper().put(PropertyKeys.top, top);
347 }
348
349 public org.apache.myfaces.tobago.layout.Measure getMaximumHeight() {
350 Object object = getStateHelper().eval(PropertyKeys.maximumHeight);
351 if (object != null) {
352 return Measure.valueOf(object);
353 }
354 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMaximumHeight(getFacesContext(), this);
355 }
356
357 public void setMaximumHeight(org.apache.myfaces.tobago.layout.Measure maximumHeight) {
358 getStateHelper().put(PropertyKeys.maximumHeight, maximumHeight);
359 }
360
361
362
363
364
365 public org.apache.myfaces.tobago.layout.Measure getCurrentWidth() {
366 Object object = getStateHelper().eval(PropertyKeys.currentWidth);
367 if (object != null) {
368 return Measure.valueOf(object);
369 }
370 return getWidth();
371 }
372
373 public void setCurrentWidth(org.apache.myfaces.tobago.layout.Measure currentWidth) {
374 getStateHelper().put(PropertyKeys.currentWidth, currentWidth);
375 }
376
377 public org.apache.myfaces.tobago.layout.Measure getMarginTop() {
378 Object object = getStateHelper().eval(PropertyKeys.marginTop);
379 if (object != null) {
380 return Measure.valueOf(object);
381 }
382 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginTop(getFacesContext(), this);
383 }
384
385 public void setMarginTop(org.apache.myfaces.tobago.layout.Measure marginTop) {
386 getStateHelper().put(PropertyKeys.marginTop, marginTop);
387 }
388
389
390
391
392
393 public org.apache.myfaces.tobago.layout.Measure getWidth() {
394 Object object = getStateHelper().eval(PropertyKeys.width);
395 if (object != null) {
396 return Measure.valueOf(object);
397 }
398 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getWidth(getFacesContext(), this);
399 }
400
401 public void setWidth(org.apache.myfaces.tobago.layout.Measure width) {
402 getStateHelper().put(PropertyKeys.width, width);
403 }
404
405 public org.apache.myfaces.tobago.layout.Measure getMarginRight() {
406 Object object = getStateHelper().eval(PropertyKeys.marginRight);
407 if (object != null) {
408 return Measure.valueOf(object);
409 }
410 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginRight(getFacesContext(), this);
411 }
412
413 public void setMarginRight(org.apache.myfaces.tobago.layout.Measure marginRight) {
414 getStateHelper().put(PropertyKeys.marginRight, marginRight);
415 }
416
417 public org.apache.myfaces.tobago.layout.Measure getPreferredHeight() {
418 Object object = getStateHelper().eval(PropertyKeys.preferredHeight);
419 if (object != null) {
420 return Measure.valueOf(object);
421 }
422 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getPreferredHeight(getFacesContext(), this);
423 }
424
425 public void setPreferredHeight(org.apache.myfaces.tobago.layout.Measure preferredHeight) {
426 getStateHelper().put(PropertyKeys.preferredHeight, preferredHeight);
427 }
428
429
430
431
432
433
434
435 public boolean isJsfResource() {
436 Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.jsfResource);
437 if (bool != null) {
438 return bool;
439 }
440 return false;
441 }
442
443 public void setJsfResource(boolean jsfResource) {
444 getStateHelper().put(PropertyKeys.jsfResource, jsfResource);
445 }
446
447
448
449
450
451
452
453
454 public java.lang.String getResource() {
455 return (java.lang.String) getStateHelper().eval(PropertyKeys.resource);
456 }
457
458 public void setResource(java.lang.String resource) {
459 getStateHelper().put(PropertyKeys.resource, resource);
460 }
461
462
463
464
465
466 public org.apache.myfaces.tobago.layout.Measure getCurrentHeight() {
467 Object object = getStateHelper().eval(PropertyKeys.currentHeight);
468 if (object != null) {
469 return Measure.valueOf(object);
470 }
471 return getHeight();
472 }
473
474 public void setCurrentHeight(org.apache.myfaces.tobago.layout.Measure currentHeight) {
475 getStateHelper().put(PropertyKeys.currentHeight, currentHeight);
476 }
477
478
479
480
481
482
483 public boolean isTransition() {
484 Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.transition);
485 if (bool != null) {
486 return bool;
487 }
488 return true;
489 }
490
491 public void setTransition(boolean transition) {
492 getStateHelper().put(PropertyKeys.transition, transition);
493 }
494
495
496
497
498
499 public java.lang.String getImage() {
500 return (java.lang.String) getStateHelper().eval(PropertyKeys.image);
501 }
502
503 public void setImage(java.lang.String image) {
504 getStateHelper().put(PropertyKeys.image, image);
505 }
506
507
508
509
510
511 public org.apache.myfaces.tobago.layout.Display getDisplay() {
512 return (org.apache.myfaces.tobago.layout.Display) getStateHelper().eval(PropertyKeys.display);
513 }
514
515 public void setDisplay(org.apache.myfaces.tobago.layout.Display display) {
516 getStateHelper().put(PropertyKeys.display, display);
517 }
518
519
520
521
522
523
524 public java.lang.String getLabel() {
525 return (java.lang.String) getStateHelper().eval(PropertyKeys.label);
526 }
527
528 public void setLabel(java.lang.String label) {
529 getStateHelper().put(PropertyKeys.label, label);
530 }
531
532 public org.apache.myfaces.tobago.layout.Measure getMaximumWidth() {
533 Object object = getStateHelper().eval(PropertyKeys.maximumWidth);
534 if (object != null) {
535 return Measure.valueOf(object);
536 }
537 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMaximumWidth(getFacesContext(), this);
538 }
539
540 public void setMaximumWidth(org.apache.myfaces.tobago.layout.Measure maximumWidth) {
541 getStateHelper().put(PropertyKeys.maximumWidth, maximumWidth);
542 }
543
544 public org.apache.myfaces.tobago.layout.Measure getPreferredWidth() {
545 Object object = getStateHelper().eval(PropertyKeys.preferredWidth);
546 if (object != null) {
547 return Measure.valueOf(object);
548 }
549 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getPreferredWidth(getFacesContext(), this);
550 }
551
552 public void setPreferredWidth(org.apache.myfaces.tobago.layout.Measure preferredWidth) {
553 getStateHelper().put(PropertyKeys.preferredWidth, preferredWidth);
554 }
555
556 public org.apache.myfaces.tobago.layout.Measure getMarginBottom() {
557 Object object = getStateHelper().eval(PropertyKeys.marginBottom);
558 if (object != null) {
559 return Measure.valueOf(object);
560 }
561 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginBottom(getFacesContext(), this);
562 }
563
564 public void setMarginBottom(org.apache.myfaces.tobago.layout.Measure marginBottom) {
565 getStateHelper().put(PropertyKeys.marginBottom, marginBottom);
566 }
567
568
569
570
571
572 public java.lang.Integer getVerticalIndex() {
573 Number value = (Number) getStateHelper().eval(PropertyKeys.verticalIndex);
574 if (value != null) {
575 return value.intValue();
576 }
577 return null;
578 }
579
580 public void setVerticalIndex(java.lang.Integer verticalIndex) {
581 getStateHelper().put(PropertyKeys.verticalIndex, verticalIndex);
582 }
583
584
585
586
587
588 public String[] getRenderedPartially() {
589 Object strArray = getStateHelper().eval(PropertyKeys.renderedPartially);
590 if (strArray != null) {
591 if (strArray instanceof String[]) {
592 return (String[]) strArray;
593 } else if (strArray instanceof String) {
594 String[] strings = StringUtils.split((String) strArray, ", ");
595 List<String> result = new ArrayList<String>(strings.length);
596 for (String string : strings) {
597 if (string.trim().length() != 0) {
598 result.add(string.trim());
599 }
600 }
601 return result.toArray(new String[result.size()]);
602 } else if (strArray == null) {
603 return ArrayUtils.EMPTY_STRING_ARRAY;
604 } else {
605 return new String[]{strArray.toString()};
606 }
607 }
608 return ArrayUtils.EMPTY_STRING_ARRAY;
609 }
610
611 public void setRenderedPartially(String[] renderedPartially) {
612 getStateHelper().put(PropertyKeys.renderedPartially, renderedPartially);
613 }
614
615
616
617
618
619
620 public java.lang.String getTarget() {
621 return (java.lang.String) getStateHelper().eval(PropertyKeys.target);
622 }
623
624 public void setTarget(java.lang.String target) {
625 getStateHelper().put(PropertyKeys.target, target);
626 }
627
628 public org.apache.myfaces.tobago.context.Markup getCurrentMarkup() {
629 if (currentMarkup != null) {
630 return currentMarkup;
631 }
632 return null;
633 }
634
635 public void setCurrentMarkup(org.apache.myfaces.tobago.context.Markup currentMarkup) {
636 this.currentMarkup = currentMarkup;
637 }
638
639
640
641
642
643 public java.lang.String getOnclick() {
644 return (java.lang.String) getStateHelper().eval(PropertyKeys.onclick);
645 }
646
647 public void setOnclick(java.lang.String onclick) {
648 getStateHelper().put(PropertyKeys.onclick, onclick);
649 }
650
651
652
653
654
655 public java.lang.Integer getHorizontalIndex() {
656 Number value = (Number) getStateHelper().eval(PropertyKeys.horizontalIndex);
657 if (value != null) {
658 return value.intValue();
659 }
660 return null;
661 }
662
663 public void setHorizontalIndex(java.lang.Integer horizontalIndex) {
664 getStateHelper().put(PropertyKeys.horizontalIndex, horizontalIndex);
665 }
666
667
668
669
670
671 public boolean isDisabled() {
672 Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.disabled);
673 if (bool != null) {
674 return bool;
675 }
676 return false;
677 }
678
679 public void setDisabled(boolean disabled) {
680 getStateHelper().put(PropertyKeys.disabled, disabled);
681 }
682
683 public Object saveState(FacesContext context) {
684 currentMarkup = null;
685 return super.saveState(context);
686 }
687
688
689 }