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.AbstractUIButton;
25  import org.apache.myfaces.tobago.renderkit.css.CustomClass;
26  import org.apache.myfaces.tobago.renderkit.css.Style;
27  import org.apache.myfaces.tobago.internal.util.ArrayUtils;
28  import org.apache.myfaces.tobago.internal.util.StringUtils;
29  import org.apache.myfaces.tobago.internal.util.Deprecation;
30  import javax.el.ELException;
31  import javax.faces.FacesException;
32  import java.util.Arrays;
33  import java.util.ArrayList;
34  import java.util.Collection;
35  import java.util.List;
36  import javax.el.MethodExpression;
37  import javax.el.ValueExpression;
38  
39  /** 
40   Renders a button element.
41    * UIComponent class, generated from template {@code component.stg} with class
42    * {@link org.apache.myfaces.tobago.internal.taglib.component.ButtonTagDeclaration}.
43   */
44  public class UIButton
45      extends AbstractUIButton implements SupportsAccessKey, Visual {
46  
47    public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.Button";
48  
49    public static final String COMPONENT_FAMILY = "javax.faces.Command";
50  
51    private static final Collection<String> EVENT_NAMES = Arrays.asList("click", "dblclick", "focus", "blur");
52  
53    @Override
54    public Collection<String> getEventNames() {
55      return EVENT_NAMES;
56    }
57  
58    @Override
59    public String getDefaultEventName() {
60      return "click";
61    }
62  
63  
64    enum PropertyKeys {
65      image,
66      markup,
67      link,
68      tabIndex,
69      confirmation,
70      label,
71      transition,
72      target,
73      defaultCommand,
74      accessKey,
75      customClass,
76      style,
77      tip,
78      omit,
79    }
80  
81    public String getFamily() {
82      return COMPONENT_FAMILY;
83    }
84  
85  
86    /**
87    Url to an image to display.
88  
89    */
90    public java.lang.String getImage() {
91      return (java.lang.String) getStateHelper().eval(PropertyKeys.image);
92    }
93  
94    public void setImage(java.lang.String image) {
95      getStateHelper().put(PropertyKeys.image, image);
96    }
97  
98    public org.apache.myfaces.tobago.context.Markup getMarkup() {
99      Object object = getStateHelper().eval(PropertyKeys.markup);
100     if (object != null) {
101       return Markup.valueOf(object);
102     }
103     return null;
104   }
105 
106   public void setMarkup(org.apache.myfaces.tobago.context.Markup markup) {
107     getStateHelper().put(PropertyKeys.markup, markup);
108   }
109 
110   /**
111   Link to an arbitrary URL, either an internal link or an external link.
112 
113    <dl>
114      <dt>internal absolute link</dt>
115      <dd>Starts with a slash '/' character. The context path will be added.
116          A session id will be added, if needed.</dd>
117      <dt>external link</dt>
118      <dd>Starts with protocol followed by a colon ':' character.
119          The link will not be modified.</dd>
120      <dt>internal relative link</dt>
121      <dd>Any other strings. A session id will be added, if needed.</dd>
122    </dl>
123 
124   */
125   public java.lang.String getLink() {
126     return (java.lang.String) getStateHelper().eval(PropertyKeys.link);
127   }
128 
129   public void setLink(java.lang.String link) {
130     getStateHelper().put(PropertyKeys.link, link);
131   }
132 
133   /**
134   Controls the navigation of the focus through the
135    input controls on a page with the Tab-Key.
136    The navigation starts from the element with
137    the lowest tabIndex value to the element with the highest value.
138    Elements that have identical tabIndex values should be navigated
139    in the order they appear in the character stream
140    Elements that are disabled or with a negative tabIndex
141    do not participate in the tabbing order.
142 
143   */
144   public java.lang.Integer getTabIndex() {
145     Number value  = (Number) getStateHelper().eval(PropertyKeys.tabIndex);
146     if (value != null) {
147       return value.intValue();
148     }
149     return null;
150   }
151 
152   public void setTabIndex(java.lang.Integer tabIndex) {
153     getStateHelper().put(PropertyKeys.tabIndex, tabIndex);
154   }
155 
156   /**
157   Text to use as confirmation message.
158 
159   */
160   public java.lang.String getConfirmation() {
161     return (java.lang.String) getStateHelper().eval(PropertyKeys.confirmation);
162   }
163 
164   public void setConfirmation(java.lang.String confirmation) {
165     getStateHelper().put(PropertyKeys.confirmation, confirmation);
166   }
167 
168   /**
169   A localized user presentable label for this component.
170 
171   */
172   public java.lang.String getLabel() {
173     return (java.lang.String) getStateHelper().eval(PropertyKeys.label);
174   }
175 
176   public void setLabel(java.lang.String label) {
177     getStateHelper().put(PropertyKeys.label, label);
178   }
179 
180   /**
181   Specify, if the command calls an JSF-Action.
182    Useful to switch off the Double-Submit-Check and Waiting-Behavior.
183   <br>Default: <code>true</code>
184   */
185   public boolean isTransition() {
186     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.transition);
187     if (bool != null) {
188       return bool;
189     }
190     return true;
191   }
192 
193   public void setTransition(boolean transition) {
194     getStateHelper().put(PropertyKeys.transition, transition);
195   }
196 
197   /**
198   Name of a frame where the resource retrieved via this hyperlink is to be
199    displayed.
200 
201   */
202   public java.lang.String getTarget() {
203     return (java.lang.String) getStateHelper().eval(PropertyKeys.target);
204   }
205 
206   public void setTarget(java.lang.String target) {
207     getStateHelper().put(PropertyKeys.target, target);
208   }
209 
210   /**
211   If true the command is executed as default -- for example if the
212    user presses the enter key inside a related input field.
213   <br>Default: <code>false</code>
214   */
215   public boolean isDefaultCommand() {
216     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.defaultCommand);
217     if (bool != null) {
218       return bool;
219     }
220     return false;
221   }
222 
223   public void setDefaultCommand(boolean defaultCommand) {
224     getStateHelper().put(PropertyKeys.defaultCommand, defaultCommand);
225   }
226 
227   /**
228   The access key of this control.
229 
230   */
231   public java.lang.Character getAccessKey() {
232     return (java.lang.Character) getStateHelper().eval(PropertyKeys.accessKey);
233   }
234 
235   public void setAccessKey(java.lang.Character accessKey) {
236     getStateHelper().put(PropertyKeys.accessKey, accessKey);
237   }
238 
239   /**
240   Sets a CSS class in its parent, if the parent supports it.
241 
242    Which this feature it is possible to put a CSS class name into a component with the &lt;tc:style&gt; tag. Example:
243 
244    <pre>
245    &lt;tc:in&gt;
246      &lt;tc:style customClass="my-emphasized"/&gt;
247    &lt;/tc:in&gt;
248    </pre>
249 
250    One capability is, to used external CSS libs.
251    <br>
252    This feature should not be used imprudent.
253    Because it might be unstable against changes in the renderered HTML code.
254 
255   */
256   public org.apache.myfaces.tobago.renderkit.css.CustomClass getCustomClass() {
257     return (org.apache.myfaces.tobago.renderkit.css.CustomClass) getStateHelper().eval(PropertyKeys.customClass);
258   }
259 
260   public void setCustomClass(org.apache.myfaces.tobago.renderkit.css.CustomClass customClass) {
261     getStateHelper().put(PropertyKeys.customClass, customClass);
262   }
263 
264   /**
265   For internal use. Used for rendering, if there is a child tag &lt;tc:style&gt;
266 
267   */
268   public org.apache.myfaces.tobago.renderkit.css.Style getStyle() {
269     return (org.apache.myfaces.tobago.renderkit.css.Style) getStateHelper().eval(PropertyKeys.style);
270   }
271 
272   public void setStyle(org.apache.myfaces.tobago.renderkit.css.Style style) {
273     getStateHelper().put(PropertyKeys.style, style);
274   }
275 
276   /**
277   Text value to display as tooltip.
278 
279   */
280   public java.lang.String getTip() {
281     return (java.lang.String) getStateHelper().eval(PropertyKeys.tip);
282   }
283 
284   public void setTip(java.lang.String tip) {
285     getStateHelper().put(PropertyKeys.tip, tip);
286   }
287 
288   /**
289   Flag indicating that the action of this element, will not be executed from client side
290    (e. g. when the user clicks a button.
291    When setting this value to true, the action will not be executed by the Tobago, but it can executed
292    by JavaScript.
293    This attribute is useful, when you want to add JavaScript event handlers to commands manually.
294    In this case you usually don't want a submit with a full reload of the page.
295   <br>Default: <code>false</code>
296   */
297   public boolean isOmit() {
298     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.omit);
299     if (bool != null) {
300       return bool;
301     }
302     return false;
303   }
304 
305   public void setOmit(boolean omit) {
306     getStateHelper().put(PropertyKeys.omit, omit);
307   }
308 
309 
310 }