001    // ---------- Attention: Generated code, please do not modify! -----------  
002    
003    /*
004     * Licensed to the Apache Software Foundation (ASF) under one or more
005     * contributor license agreements.  See the NOTICE file distributed with
006     * this work for additional information regarding copyright ownership.
007     * The ASF licenses this file to You under the Apache License, Version 2.0
008     * (the "License"); you may not use this file except in compliance with
009     * the License.  You may obtain a copy of the License at
010     *
011     *      http://www.apache.org/licenses/LICENSE-2.0
012     *
013     * Unless required by applicable law or agreed to in writing, software
014     * distributed under the License is distributed on an "AS IS" BASIS,
015     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016     * See the License for the specific language governing permissions and
017     * limitations under the License.
018     */
019    
020    package org.apache.myfaces.tobago.component;
021    
022    import javax.faces.context.FacesContext;
023    import org.apache.commons.lang.ArrayUtils;
024    import org.apache.commons.lang.StringUtils;
025    import org.apache.myfaces.tobago.component.MethodBindingToMethodExpression;
026    import org.apache.myfaces.tobago.component.MethodExpressionToMethodBinding;
027    import org.apache.myfaces.tobago.internal.util.Deprecation;
028    import org.apache.myfaces.tobago.renderkit.MarginValues;
029    import org.apache.myfaces.tobago.renderkit.SpacingValues;
030    import org.apache.myfaces.tobago.renderkit.LayoutComponentRenderer;
031    import javax.el.ELException;
032    import javax.faces.FacesException;
033    import java.util.ArrayList;
034    import java.util.List;
035    import javax.el.MethodExpression;
036    import javax.el.ValueExpression;
037    
038    /** 
039     Renders a button element.
040      * UIComponent class, generated from template {@code component1.2.stg} with class
041      * {@link org.apache.myfaces.tobago.internal.taglib.component.ButtonTagDeclaration}.
042     */
043    public class UIButton
044        extends UICommand  {
045    
046      public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.Button";
047    
048      private java.lang.Character accessKey;
049      private java.lang.String labelWithAccessKey;
050      private java.lang.Boolean defaultCommand;
051      private java.lang.Integer tabIndex;
052      private java.lang.String tip;
053      private java.lang.Boolean inline;
054      private java.lang.String image;
055      private java.lang.String label;
056    
057    
058      /**
059      Deprecated! Has not longer any function.
060    
061      @deprecated*/
062      @Deprecated
063      public java.lang.Character getAccessKey() {
064        if (accessKey != null) {
065          return accessKey;
066        }
067        ValueExpression ve = getValueExpression("accessKey");
068        if (ve != null) {
069          try {
070            return (java.lang.Character) ve.getValue(getFacesContext().getELContext());
071          } catch (ELException e) {
072                      throw new FacesException(e);
073              }
074        }
075        return null;
076      }
077    
078      @Deprecated
079      public void setAccessKey(java.lang.Character accessKey) {
080        this.accessKey = accessKey;
081      }
082    
083      /**
084      Deprecated! Use 'label' instead.
085       Text value to display as label.
086       If text contains an underscore the next character overwrites 'accesskey'.
087    
088      @deprecated*/
089      @Deprecated
090      public java.lang.String getLabelWithAccessKey() {
091        if (labelWithAccessKey != null) {
092          return labelWithAccessKey;
093        }
094        ValueExpression ve = getValueExpression("labelWithAccessKey");
095        if (ve != null) {
096          try {
097            return (java.lang.String) ve.getValue(getFacesContext().getELContext());
098          } catch (ELException e) {
099                      throw new FacesException(e);
100              }
101        }
102        return null;
103      }
104    
105      @Deprecated
106      public void setLabelWithAccessKey(java.lang.String labelWithAccessKey) {
107        this.labelWithAccessKey = labelWithAccessKey;
108      }
109    
110      /**
111      If true the command is executed as default -- for example if the
112       user presses the enter key inside a related input field.
113      <br />Default: <code>false</code>
114      */
115      public boolean isDefaultCommand() {
116        if (defaultCommand != null) {
117          return defaultCommand;
118        }
119        ValueExpression ve = getValueExpression("defaultCommand");
120        if (ve != null) {
121          try {
122            Boolean bool = (Boolean) ve.getValue(getFacesContext().getELContext());
123            if (bool != null) {
124              return bool;
125            }
126          } catch (ELException e) {
127                      throw new FacesException(e);
128              }
129        }
130        return false;
131      }
132    
133      public void setDefaultCommand(boolean defaultCommand) {
134        this.defaultCommand = defaultCommand;
135      }
136    
137      /**
138      Controls the navigation of the focus through the
139       input controls on a page with the Tab-Key.
140       The navigation starts from the element with
141       the lowest tabIndex value to the element with the highest value.
142       Elements that have identical tabIndex values should be navigated
143       in the order they appear in the character stream
144       Elements that are disabled or with a negative tabIndex
145       do not participate in the tabbing order.
146    
147      */
148      public java.lang.Integer getTabIndex() {
149        if (tabIndex != null) {
150          return tabIndex;
151        }
152        ValueExpression ve = getValueExpression("tabIndex");
153        if (ve != null) {
154          try {
155            Number number = (Number) ve.getValue(getFacesContext().getELContext());
156            if (number != null) {
157              return number.intValue();
158            }
159          } catch (ELException e) {
160                      throw new FacesException(e);
161              }
162        }
163        return null;
164      }
165    
166      public void setTabIndex(java.lang.Integer tabIndex) {
167        this.tabIndex = tabIndex;
168      }
169    
170      /**
171      Text value to display as tooltip.
172    
173      */
174      public java.lang.String getTip() {
175        if (tip != null) {
176          return tip;
177        }
178        ValueExpression ve = getValueExpression("tip");
179        if (ve != null) {
180          try {
181            return (java.lang.String) ve.getValue(getFacesContext().getELContext());
182          } catch (ELException e) {
183                      throw new FacesException(e);
184              }
185        }
186        return null;
187      }
188    
189      public void setTip(java.lang.String tip) {
190        this.tip = tip;
191      }
192    
193      /**
194      Flag indicating this component should rendered as an inline element.
195      <br />Default: <code>false</code>
196      */
197      public boolean isInline() {
198        if (inline != null) {
199          return inline;
200        }
201        ValueExpression ve = getValueExpression("inline");
202        if (ve != null) {
203          try {
204            Boolean bool = (Boolean) ve.getValue(getFacesContext().getELContext());
205            if (bool != null) {
206              return bool;
207            }
208          } catch (ELException e) {
209                      throw new FacesException(e);
210              }
211        }
212        return false;
213      }
214    
215      public void setInline(boolean inline) {
216        this.inline = inline;
217      }
218    
219      /**
220      Url to an image to display.
221    
222      */
223      public java.lang.String getImage() {
224        if (image != null) {
225          return image;
226        }
227        ValueExpression ve = getValueExpression("image");
228        if (ve != null) {
229          try {
230            return (java.lang.String) ve.getValue(getFacesContext().getELContext());
231          } catch (ELException e) {
232                      throw new FacesException(e);
233              }
234        }
235        return null;
236      }
237    
238      public void setImage(java.lang.String image) {
239        this.image = image;
240      }
241    
242      /**
243      Text value to display as label.
244       If text contains an underscore the next character is used as accesskey.
245    
246      */
247      public java.lang.String getLabel() {
248        if (label != null) {
249          return label;
250        }
251        ValueExpression ve = getValueExpression("label");
252        if (ve != null) {
253          try {
254            return (java.lang.String) ve.getValue(getFacesContext().getELContext());
255          } catch (ELException e) {
256                      throw new FacesException(e);
257              }
258        }
259        return null;
260      }
261    
262      public void setLabel(java.lang.String label) {
263        this.label = label;
264      }
265    
266      public void restoreState(FacesContext context, Object componentState) {
267        Object[] values = (Object[]) componentState;
268        super.restoreState(context, values[0]);
269        accessKey = (java.lang.Character) values[1];
270        labelWithAccessKey = (java.lang.String) values[2];
271        defaultCommand = (java.lang.Boolean) values[3];
272        tabIndex = (java.lang.Integer) values[4];
273        tip = (java.lang.String) values[5];
274        inline = (java.lang.Boolean) values[6];
275        image = (java.lang.String) values[7];
276        label = (java.lang.String) values[8];
277      }
278    
279      public Object saveState(FacesContext context) {
280        Object[] values = new Object[9];
281        values[0] = super.saveState(context);
282        values[1] = accessKey;
283        values[2] = labelWithAccessKey;
284        values[3] = defaultCommand;
285        values[4] = tabIndex;
286        values[5] = tip;
287        values[6] = inline;
288        values[7] = image;
289        values[8] = label;
290        return values;
291      }
292    
293    
294    }