View Javadoc

1   // ---------- Attention: Generated code, please do not modify! -----------  
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one or more
5    * contributor license agreements.  See the NOTICE file distributed with
6    * this work for additional information regarding copyright ownership.
7    * The ASF licenses this file to You under the Apache License, Version 2.0
8    * (the "License"); you may not use this file except in compliance with
9    * the License.  You may obtain a copy of the License at
10   *
11   *      http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
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.LayoutComponent;
27  import org.apache.myfaces.tobago.layout.Measure;
28  import org.apache.myfaces.tobago.internal.util.ArrayUtils;
29  import org.apache.myfaces.tobago.internal.util.StringUtils;
30  import org.apache.myfaces.tobago.internal.util.Deprecation;
31  import org.apache.myfaces.tobago.renderkit.MarginValues;
32  import org.apache.myfaces.tobago.renderkit.SpacingValues;
33  import org.apache.myfaces.tobago.renderkit.LayoutComponentRenderer;
34  import javax.el.ELException;
35  import javax.faces.FacesException;
36  import java.util.ArrayList;
37  import java.util.List;
38  import javax.el.MethodExpression;
39  import javax.el.ValueExpression;
40  
41  /** 
42   Renders a button element.
43    * UIComponent class, generated from template {@code component2.0.stg} with class
44    * {@link org.apache.myfaces.tobago.internal.taglib.component.ButtonTagDeclaration}.
45   */
46  public class UIButton
47      extends AbstractUICommand implements SupportsAccessKey, LayoutComponent, SupportsMarkup {
48  
49    public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.Button";
50  
51    public static final String COMPONENT_FAMILY = "javax.faces.Command";
52  
53    private org.apache.myfaces.tobago.context.Markup currentMarkup;
54  
55    enum PropertyKeys {
56      accessKey,
57      markup,
58      marginLeft,
59      link,
60      defaultCommand,
61      tabIndex,
62      minimumHeight,
63      tip,
64      height,
65      minimumWidth,
66      rowSpan,
67      left,
68      columnSpan,
69      top,
70      maximumHeight,
71      currentWidth,
72      marginTop,
73      width,
74      marginRight,
75      preferredHeight,
76      jsfResource,
77      resource,
78      currentHeight,
79      transition,
80      image,
81      display,
82      label,
83      maximumWidth,
84      preferredWidth,
85      marginBottom,
86      verticalIndex,
87      omit,
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   The access key of this control.
102 
103   */
104   public java.lang.Character getAccessKey() {
105     return (java.lang.Character) getStateHelper().eval(PropertyKeys.accessKey);
106   }
107 
108   public void setAccessKey(java.lang.Character accessKey) {
109     getStateHelper().put(PropertyKeys.accessKey, accessKey);
110   }
111 
112   public org.apache.myfaces.tobago.context.Markup getMarkup() {
113     Object object = getStateHelper().eval(PropertyKeys.markup);
114     if (object != null) {
115       return Markup.valueOf(object);
116     }
117     return null;
118   }
119 
120   public void setMarkup(org.apache.myfaces.tobago.context.Markup markup) {
121     getStateHelper().put(PropertyKeys.markup, markup);
122   }
123 
124   public org.apache.myfaces.tobago.layout.Measure getMarginLeft() {
125     Object object = getStateHelper().eval(PropertyKeys.marginLeft);
126     if (object != null) {
127        return Measure.valueOf(object);
128     }
129     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginLeft(getFacesContext(), this) : Measure.ZERO;
130   }
131 
132   public void setMarginLeft(org.apache.myfaces.tobago.layout.Measure marginLeft) {
133     getStateHelper().put(PropertyKeys.marginLeft, marginLeft);
134   }
135 
136   /**
137   Link to an arbitrary URL, either an internal link or an external link.
138 
139    <dl>
140      <dt>internal absolute link</dt>
141      <dd>Starts with a slash '/' character. The context path will be added.
142          A session id will be added, if needed.</dd>
143      <dt>external link</dt>
144      <dd>Starts with protocol followed by a colon ':' character.
145          The link will not be modified.</dd>
146      <dt>internal relative link</dt>
147      <dd>Any other strings. A session id will be added, if needed.</dd>
148    </dl>
149 
150   */
151   public java.lang.String getLink() {
152     return (java.lang.String) getStateHelper().eval(PropertyKeys.link);
153   }
154 
155   public void setLink(java.lang.String link) {
156     getStateHelper().put(PropertyKeys.link, link);
157   }
158 
159   /**
160   If true the command is executed as default -- for example if the
161    user presses the enter key inside a related input field.
162   <br />Default: <code>false</code>
163   */
164   public boolean isDefaultCommand() {
165     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.defaultCommand);
166     if (bool != null) {
167       return bool;
168     }
169     return false;
170   }
171 
172   public void setDefaultCommand(boolean defaultCommand) {
173     getStateHelper().put(PropertyKeys.defaultCommand, defaultCommand);
174   }
175 
176   /**
177   Controls the navigation of the focus through the
178    input controls on a page with the Tab-Key.
179    The navigation starts from the element with
180    the lowest tabIndex value to the element with the highest value.
181    Elements that have identical tabIndex values should be navigated
182    in the order they appear in the character stream
183    Elements that are disabled or with a negative tabIndex
184    do not participate in the tabbing order.
185 
186   */
187   public java.lang.Integer getTabIndex() {
188     Number value  = (Number) getStateHelper().eval(PropertyKeys.tabIndex);
189     if (value != null) {
190       return value.intValue();
191     }
192     return null;
193   }
194 
195   public void setTabIndex(java.lang.Integer tabIndex) {
196     getStateHelper().put(PropertyKeys.tabIndex, tabIndex);
197   }
198 
199   public org.apache.myfaces.tobago.layout.Measure getMinimumHeight() {
200     Object object = getStateHelper().eval(PropertyKeys.minimumHeight);
201     if (object != null) {
202        return Measure.valueOf(object);
203     }
204     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMinimumHeight(getFacesContext(), this) : Measure.ZERO;
205   }
206 
207   public void setMinimumHeight(org.apache.myfaces.tobago.layout.Measure minimumHeight) {
208     getStateHelper().put(PropertyKeys.minimumHeight, minimumHeight);
209   }
210 
211   /**
212   Text value to display as tooltip.
213 
214   */
215   public java.lang.String getTip() {
216     return (java.lang.String) getStateHelper().eval(PropertyKeys.tip);
217   }
218 
219   public void setTip(java.lang.String tip) {
220     getStateHelper().put(PropertyKeys.tip, tip);
221   }
222 
223   /**
224   This value will usually be set by the layout manager.
225 
226   */
227   public org.apache.myfaces.tobago.layout.Measure getHeight() {
228     Object object = getStateHelper().eval(PropertyKeys.height);
229     if (object != null) {
230        return Measure.valueOf(object);
231     }
232     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getHeight(getFacesContext(), this) : Measure.ZERO;
233   }
234 
235   public void setHeight(org.apache.myfaces.tobago.layout.Measure height) {
236     getStateHelper().put(PropertyKeys.height, height);
237   }
238 
239   public org.apache.myfaces.tobago.layout.Measure getMinimumWidth() {
240     Object object = getStateHelper().eval(PropertyKeys.minimumWidth);
241     if (object != null) {
242        return Measure.valueOf(object);
243     }
244     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMinimumWidth(getFacesContext(), this) : Measure.ZERO;
245   }
246 
247   public void setMinimumWidth(org.apache.myfaces.tobago.layout.Measure minimumWidth) {
248     getStateHelper().put(PropertyKeys.minimumWidth, minimumWidth);
249   }
250 
251   public java.lang.Integer getRowSpan() {
252     Number value  = (Number) getStateHelper().eval(PropertyKeys.rowSpan);
253     if (value != null) {
254       return value.intValue();
255     }
256     return 1;
257   }
258 
259   public void setRowSpan(java.lang.Integer rowSpan) {
260     getStateHelper().put(PropertyKeys.rowSpan, rowSpan);
261   }
262 
263   /**
264   This value will usually be set by the layout manager.
265 
266   */
267   public org.apache.myfaces.tobago.layout.Measure getLeft() {
268     Object object = getStateHelper().eval(PropertyKeys.left);
269     if (object != null) {
270        return Measure.valueOf(object);
271     }
272     return null;
273   }
274 
275   public void setLeft(org.apache.myfaces.tobago.layout.Measure left) {
276     getStateHelper().put(PropertyKeys.left, left);
277   }
278 
279   public java.lang.Integer getColumnSpan() {
280     Number value  = (Number) getStateHelper().eval(PropertyKeys.columnSpan);
281     if (value != null) {
282       return value.intValue();
283     }
284     return 1;
285   }
286 
287   public void setColumnSpan(java.lang.Integer columnSpan) {
288     getStateHelper().put(PropertyKeys.columnSpan, columnSpan);
289   }
290 
291   /**
292   This value will usually be set by the layout manager.
293 
294   */
295   public org.apache.myfaces.tobago.layout.Measure getTop() {
296     Object object = getStateHelper().eval(PropertyKeys.top);
297     if (object != null) {
298        return Measure.valueOf(object);
299     }
300     return null;
301   }
302 
303   public void setTop(org.apache.myfaces.tobago.layout.Measure top) {
304     getStateHelper().put(PropertyKeys.top, top);
305   }
306 
307   public org.apache.myfaces.tobago.layout.Measure getMaximumHeight() {
308     Object object = getStateHelper().eval(PropertyKeys.maximumHeight);
309     if (object != null) {
310        return Measure.valueOf(object);
311     }
312     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMaximumHeight(getFacesContext(), this) : Measure.ZERO;
313   }
314 
315   public void setMaximumHeight(org.apache.myfaces.tobago.layout.Measure maximumHeight) {
316     getStateHelper().put(PropertyKeys.maximumHeight, maximumHeight);
317   }
318 
319   /**
320   This value will usually be set by the layout manager. It holds the current width computed by the layout manager.
321 
322   */
323   public org.apache.myfaces.tobago.layout.Measure getCurrentWidth() {
324     Object object = getStateHelper().eval(PropertyKeys.currentWidth);
325     if (object != null) {
326        return Measure.valueOf(object);
327     }
328     return getWidth();
329   }
330 
331   public void setCurrentWidth(org.apache.myfaces.tobago.layout.Measure currentWidth) {
332     getStateHelper().put(PropertyKeys.currentWidth, currentWidth);
333   }
334 
335   public org.apache.myfaces.tobago.layout.Measure getMarginTop() {
336     Object object = getStateHelper().eval(PropertyKeys.marginTop);
337     if (object != null) {
338        return Measure.valueOf(object);
339     }
340     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginTop(getFacesContext(), this) : Measure.ZERO;
341   }
342 
343   public void setMarginTop(org.apache.myfaces.tobago.layout.Measure marginTop) {
344     getStateHelper().put(PropertyKeys.marginTop, marginTop);
345   }
346 
347   /**
348   This value will usually be set by the layout manager.
349 
350   */
351   public org.apache.myfaces.tobago.layout.Measure getWidth() {
352     Object object = getStateHelper().eval(PropertyKeys.width);
353     if (object != null) {
354        return Measure.valueOf(object);
355     }
356     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getWidth(getFacesContext(), this) : Measure.ZERO;
357   }
358 
359   public void setWidth(org.apache.myfaces.tobago.layout.Measure width) {
360     getStateHelper().put(PropertyKeys.width, width);
361   }
362 
363   public org.apache.myfaces.tobago.layout.Measure getMarginRight() {
364     Object object = getStateHelper().eval(PropertyKeys.marginRight);
365     if (object != null) {
366        return Measure.valueOf(object);
367     }
368     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginRight(getFacesContext(), this) : Measure.ZERO;
369   }
370 
371   public void setMarginRight(org.apache.myfaces.tobago.layout.Measure marginRight) {
372     getStateHelper().put(PropertyKeys.marginRight, marginRight);
373   }
374 
375   public org.apache.myfaces.tobago.layout.Measure getPreferredHeight() {
376     Object object = getStateHelper().eval(PropertyKeys.preferredHeight);
377     if (object != null) {
378        return Measure.valueOf(object);
379     }
380     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getPreferredHeight(getFacesContext(), this) : Measure.ZERO;
381   }
382 
383   public void setPreferredHeight(org.apache.myfaces.tobago.layout.Measure preferredHeight) {
384     getStateHelper().put(PropertyKeys.preferredHeight, preferredHeight);
385   }
386 
387   /**
388   Flag indicating that the resource referenced by the resource attribute is a jsf resource.
389    That means that the url has to be processed to change the prefix or suffix (e. g. *.jsf or
390    /faces/*). Default is false.
391   <br />Default: <code>false</code>
392   */
393   public boolean isJsfResource() {
394     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.jsfResource);
395     if (bool != null) {
396       return bool;
397     }
398     return false;
399   }
400 
401   public void setJsfResource(boolean jsfResource) {
402     getStateHelper().put(PropertyKeys.jsfResource, jsfResource);
403   }
404 
405   /**
406   Link to an internal resource.
407    Resources will be processed by the resource management.
408    E. g. define help.html and it will be served help_es.html or help_de.html if available.
409    For JSF-Pages you have to set the jsfResource attribute.
410 
411   */
412   public java.lang.String getResource() {
413     return (java.lang.String) getStateHelper().eval(PropertyKeys.resource);
414   }
415 
416   public void setResource(java.lang.String resource) {
417     getStateHelper().put(PropertyKeys.resource, resource);
418   }
419 
420   /**
421   This value will usually be set by the layout manager. It holds the current height computed by the layout manager.
422 
423   */
424   public org.apache.myfaces.tobago.layout.Measure getCurrentHeight() {
425     Object object = getStateHelper().eval(PropertyKeys.currentHeight);
426     if (object != null) {
427        return Measure.valueOf(object);
428     }
429     return getHeight();
430   }
431 
432   public void setCurrentHeight(org.apache.myfaces.tobago.layout.Measure currentHeight) {
433     getStateHelper().put(PropertyKeys.currentHeight, currentHeight);
434   }
435 
436   /**
437   Specify, if the command calls an JSF-Action.
438    Useful to switch off the Double-Submit-Check and Waiting-Behavior.
439   <br />Default: <code>true</code>
440   */
441   public boolean isTransition() {
442     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.transition);
443     if (bool != null) {
444       return bool;
445     }
446     return true;
447   }
448 
449   public void setTransition(boolean transition) {
450     getStateHelper().put(PropertyKeys.transition, transition);
451   }
452 
453   /**
454   Url to an image to display.
455 
456   */
457   public java.lang.String getImage() {
458     return (java.lang.String) getStateHelper().eval(PropertyKeys.image);
459   }
460 
461   public void setImage(java.lang.String image) {
462     getStateHelper().put(PropertyKeys.image, image);
463   }
464 
465   /**
466   This attribute is for internal use only.
467 
468   */
469   public org.apache.myfaces.tobago.layout.Display getDisplay() {
470     return (org.apache.myfaces.tobago.layout.Display) getStateHelper().eval(PropertyKeys.display);
471   }
472 
473   public void setDisplay(org.apache.myfaces.tobago.layout.Display display) {
474     getStateHelper().put(PropertyKeys.display, display);
475   }
476 
477   /**
478   Text value to display as label.
479    If text contains an underscore the next character is used as accesskey (if configured so and possible).
480 
481   */
482   public java.lang.String getLabel() {
483     return (java.lang.String) getStateHelper().eval(PropertyKeys.label);
484   }
485 
486   public void setLabel(java.lang.String label) {
487     getStateHelper().put(PropertyKeys.label, label);
488   }
489 
490   public org.apache.myfaces.tobago.layout.Measure getMaximumWidth() {
491     Object object = getStateHelper().eval(PropertyKeys.maximumWidth);
492     if (object != null) {
493        return Measure.valueOf(object);
494     }
495     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMaximumWidth(getFacesContext(), this) : Measure.ZERO;
496   }
497 
498   public void setMaximumWidth(org.apache.myfaces.tobago.layout.Measure maximumWidth) {
499     getStateHelper().put(PropertyKeys.maximumWidth, maximumWidth);
500   }
501 
502   public org.apache.myfaces.tobago.layout.Measure getPreferredWidth() {
503     Object object = getStateHelper().eval(PropertyKeys.preferredWidth);
504     if (object != null) {
505        return Measure.valueOf(object);
506     }
507     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getPreferredWidth(getFacesContext(), this) : Measure.ZERO;
508   }
509 
510   public void setPreferredWidth(org.apache.myfaces.tobago.layout.Measure preferredWidth) {
511     getStateHelper().put(PropertyKeys.preferredWidth, preferredWidth);
512   }
513 
514   public org.apache.myfaces.tobago.layout.Measure getMarginBottom() {
515     Object object = getStateHelper().eval(PropertyKeys.marginBottom);
516     if (object != null) {
517        return Measure.valueOf(object);
518     }
519     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginBottom(getFacesContext(), this) : Measure.ZERO;
520   }
521 
522   public void setMarginBottom(org.apache.myfaces.tobago.layout.Measure marginBottom) {
523     getStateHelper().put(PropertyKeys.marginBottom, marginBottom);
524   }
525 
526   /**
527   This attribute is for internal use only.
528 
529   */
530   public java.lang.Integer getVerticalIndex() {
531     Number value  = (Number) getStateHelper().eval(PropertyKeys.verticalIndex);
532     if (value != null) {
533       return value.intValue();
534     }
535     return null;
536   }
537 
538   public void setVerticalIndex(java.lang.Integer verticalIndex) {
539     getStateHelper().put(PropertyKeys.verticalIndex, verticalIndex);
540   }
541 
542   /**
543   Flag indicating that the action of this element, will not be executed from client side
544    (e. g. when the user clicks a button.
545    When setting this value to true, the action will not be executed by the Tobago, but it can executed
546    by JavaScript.
547    This attribute is useful, when you want to add JavaScript event handlers to commands manually.
548    In this case you usually don't want a submit with a full reload of the page.
549   <br />Default: <code>false</code>
550   */
551   public boolean isOmit() {
552     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.omit);
553     if (bool != null) {
554       return bool;
555     }
556     return false;
557   }
558 
559   public void setOmit(boolean omit) {
560     getStateHelper().put(PropertyKeys.omit, omit);
561   }
562 
563   /**
564   <p>
565    Indicate the partially rendered Components in a case of a submit.
566    </p>
567    <p>
568    The search depends on the number of prefixed colons in the relativeId:
569    <dl>
570      <dd>colonCount == 0</dd>
571      <dt>fully relative</dt>
572      <dd>colonCount == 1</dd>
573      <dt>absolute (still normal findComponent syntax)</dt>
574      <dd>colonCount > 1</dd>
575      <dt>for each extra colon after 1, go up a naming container</dt>
576    </dl>
577    </p>
578    <p>
579    If a literal is specified the identifiers must be space delimited.
580    </p>
581 
582   */
583   public String[] getRenderedPartially() {
584     Object strArray = getStateHelper().eval(PropertyKeys.renderedPartially);
585     if (strArray != null) {
586       if (strArray instanceof String[]) {
587         return (String[]) strArray;
588       } else if (strArray instanceof String) {
589         String[] strings = StringUtils.split((String) strArray, ", ");
590         List<String> result = new ArrayList<String>(strings.length);
591         for (String string : strings) {
592           if (string.trim().length() != 0) {
593             result.add(string.trim());
594           }
595         }
596         return result.toArray(new String[result.size()]);
597       } else if (strArray == null) {
598         return org.apache.myfaces.tobago.internal.util.ArrayUtils.EMPTY_STRING_ARRAY;
599       } else {
600         return new String[]{strArray.toString()};
601       }
602     }
603     return org.apache.myfaces.tobago.internal.util.ArrayUtils.EMPTY_STRING_ARRAY;
604   }
605 
606   public void setRenderedPartially(String[] renderedPartially) {
607     getStateHelper().put(PropertyKeys.renderedPartially, renderedPartially);
608   }
609 
610   /**
611   Name of a frame where the resource retrieved via this hyperlink is to be
612    displayed.
613 
614   */
615   public java.lang.String getTarget() {
616     return (java.lang.String) getStateHelper().eval(PropertyKeys.target);
617   }
618 
619   public void setTarget(java.lang.String target) {
620     getStateHelper().put(PropertyKeys.target, target);
621   }
622 
623   public org.apache.myfaces.tobago.context.Markup getCurrentMarkup() {
624     if (currentMarkup != null) {
625       return currentMarkup;
626     }
627     return null;
628   }
629 
630   public void setCurrentMarkup(org.apache.myfaces.tobago.context.Markup currentMarkup) {
631     this.currentMarkup = currentMarkup;
632   }
633 
634   /**
635   Script to be invoked when clicked
636 
637   */
638   public java.lang.String getOnclick() {
639     return (java.lang.String) getStateHelper().eval(PropertyKeys.onclick);
640   }
641 
642   public void setOnclick(java.lang.String onclick) {
643     getStateHelper().put(PropertyKeys.onclick, onclick);
644   }
645 
646   /**
647   This attribute is for internal use only.
648 
649   */
650   public java.lang.Integer getHorizontalIndex() {
651     Number value  = (Number) getStateHelper().eval(PropertyKeys.horizontalIndex);
652     if (value != null) {
653       return value.intValue();
654     }
655     return null;
656   }
657 
658   public void setHorizontalIndex(java.lang.Integer horizontalIndex) {
659     getStateHelper().put(PropertyKeys.horizontalIndex, horizontalIndex);
660   }
661 
662   /**
663   Flag indicating that this element is disabled.
664   <br />Default: <code>false</code>
665   */
666   public boolean isDisabled() {
667     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.disabled);
668     if (bool != null) {
669       return bool;
670     }
671     return false;
672   }
673 
674   public void setDisabled(boolean disabled) {
675     getStateHelper().put(PropertyKeys.disabled, disabled);
676   }
677 
678   public Object saveState(FacesContext context) {
679     currentMarkup = null;
680     return super.saveState(context);
681   }
682 
683 }