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.internal.util.ArrayUtils;
27  import org.apache.myfaces.tobago.internal.util.StringUtils;
28  import org.apache.myfaces.tobago.internal.util.Deprecation;
29  import org.apache.myfaces.tobago.component.Tags;
30  import javax.annotation.Generated;
31  import javax.el.ELException;
32  import javax.faces.FacesException;
33  import java.util.Arrays;
34  import java.util.ArrayList;
35  import java.util.Collection;
36  import java.util.List;
37  import javax.el.MethodExpression;
38  import javax.el.ValueExpression;
39  
40  /**
41   Renders a button element.
42    * UIComponent class, generated from template {@code component.stg} with class
43    * {@link org.apache.myfaces.tobago.internal.taglib.component.ButtonTagDeclaration}.
44   */
45  @Generated("component.stg")
46  public class UIButton
47      extends AbstractUIButton implements SupportsAccessKey {
48  
49    public static final String COMPONENT_TYPE = Tags.button.componentType();
50  
51    public static final String COMPONENT_FAMILY = "javax.faces.Command";
52  
53    private static final Collection<String> EVENT_NAMES = Arrays.asList("click", "dblclick", "focus", "blur");
54  
55    @Override
56    public Collection<String> getEventNames() {
57      return EVENT_NAMES;
58    }
59  
60    @Override
61    public String getDefaultEventName() {
62      return "click";
63    }
64  
65  
66    enum PropertyKeys {
67      image,
68      markup,
69      link,
70      tabIndex,
71      confirmation,
72      label,
73      transition,
74      target,
75      defaultCommand,
76      fragment,
77      accessKey,
78      customClass,
79      tip,
80      omit,
81      outcome,
82    }
83  
84    public String getFamily() {
85      return COMPONENT_FAMILY;
86    }
87  
88  
89    /**
90    Url to an image to display.
91  
92    */
93    public java.lang.String getImage() {
94      return (java.lang.String) getStateHelper().eval(PropertyKeys.image);
95    }
96  
97    public void setImage(java.lang.String image) {
98      getStateHelper().put(PropertyKeys.image, image);
99    }
100 
101   public org.apache.myfaces.tobago.context.Markup getMarkup() {
102     Object object = getStateHelper().eval(PropertyKeys.markup);
103     if (object != null) {
104       return Markup.valueOf(object);
105     }
106     return null;
107   }
108 
109   public void setMarkup(org.apache.myfaces.tobago.context.Markup markup) {
110     getStateHelper().put(PropertyKeys.markup, markup);
111   }
112 
113   /**
114   <p>
115    Link to an arbitrary URL, either an internal link or an external link. For internal URLs, a session id will be
116    added, if needed (when cookies disabled). The context path needs to be added manually e.g. #{request.contextPath}.
117    For JSF navigation to a viewId use the outcome attribute!
118    </p>
119 
120    <p>
121    The semantic of this attributes has been changed from Tobago 3 to 4!
122    </p>
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 identifier of the page fragment which should
229    be brought into focus when the target page is
230    rendered. The value of this attribute is appended
231    to the end of target URL following a hash (#) mark.
232    This notation is part of the standard URL syntax.
233 
234   */
235   public java.lang.String getFragment() {
236     return (java.lang.String) getStateHelper().eval(PropertyKeys.fragment);
237   }
238 
239   public void setFragment(java.lang.String fragment) {
240     getStateHelper().put(PropertyKeys.fragment, fragment);
241   }
242 
243   /**
244   The access key of this control.
245 
246   */
247   public java.lang.Character getAccessKey() {
248     return (java.lang.Character) getStateHelper().eval(PropertyKeys.accessKey);
249   }
250 
251   public void setAccessKey(java.lang.Character accessKey) {
252     getStateHelper().put(PropertyKeys.accessKey, accessKey);
253   }
254 
255   /**
256   Sets a CSS class in its parent, if the parent supports it.
257 
258    Which this feature it is possible to put a CSS class name into a component with the &lt;tc:style&gt; tag. Example:
259 
260    <pre>
261    &lt;tc:in&gt;
262      &lt;tc:style customClass="my-emphasized"/&gt;
263    &lt;/tc:in&gt;
264    </pre>
265 
266    One capability is, to used external CSS libs.
267    <br>
268    This feature should not be used imprudent.
269    Because it might be unstable against changes in the renderered HTML code.
270 
271   */
272   public org.apache.myfaces.tobago.renderkit.css.CustomClass getCustomClass() {
273     return (org.apache.myfaces.tobago.renderkit.css.CustomClass) getStateHelper().eval(PropertyKeys.customClass);
274   }
275 
276   public void setCustomClass(org.apache.myfaces.tobago.renderkit.css.CustomClass customClass) {
277     getStateHelper().put(PropertyKeys.customClass, customClass);
278   }
279 
280   /**
281   Text value to display as tooltip.
282 
283   */
284   public java.lang.String getTip() {
285     return (java.lang.String) getStateHelper().eval(PropertyKeys.tip);
286   }
287 
288   public void setTip(java.lang.String tip) {
289     getStateHelper().put(PropertyKeys.tip, tip);
290   }
291 
292   /**
293   Flag indicating that the action of this element, will not be executed from client side
294    (e. g. when the user clicks a button.
295    When setting this value to true, the action will not be executed by the Tobago, but it can executed
296    by JavaScript.
297    This attribute is useful, when you want to add JavaScript event handlers to commands manually.
298    In this case you usually don't want a submit with a full reload of the page.
299   <br>Default: <code>false</code>
300   */
301   public boolean isOmit() {
302     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.omit);
303     if (bool != null) {
304       return bool;
305     }
306     return false;
307   }
308 
309   public void setOmit(boolean omit) {
310     getStateHelper().put(PropertyKeys.omit, omit);
311   }
312 
313   /**
314   Link to an internal facelet page, like the outcome of an action.
315    The context path will be added.
316    A session id will be added, if needed.
317 
318   */
319   public java.lang.String getOutcome() {
320     return (java.lang.String) getStateHelper().eval(PropertyKeys.outcome);
321   }
322 
323   public void setOutcome(java.lang.String outcome) {
324     getStateHelper().put(PropertyKeys.outcome, outcome);
325   }
326 
327 
328   @Override
329   public void restoreState(FacesContext context, Object state) {
330     // FIXME HACK for mojarra SystemEventListener state restoring bug
331     pushComponentToEL(context, this);
332     super.restoreState(context, state);
333     popComponentFromEL(context);
334   }
335 
336 }