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.ArrayList;
33  import java.util.List;
34  import javax.el.MethodExpression;
35  import javax.el.ValueExpression;
36  
37  /** 
38   Renders a button element.
39    * UIComponent class, generated from template {@code component.stg} with class
40    * {@link org.apache.myfaces.tobago.internal.taglib.component.ButtonTagDeclaration}.
41   */
42  public class UIButton
43      extends AbstractUIButton implements SupportsAccessKey, Visual {
44  
45    public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.Button";
46  
47    public static final String COMPONENT_FAMILY = "javax.faces.Command";
48  
49  
50    enum PropertyKeys {
51      image,
52      markup,
53      resource,
54      link,
55      tabIndex,
56      label,
57      transition,
58      target,
59      renderedPartially,
60      defaultCommand,
61      jsfResource,
62      accessKey,
63      customClass,
64      tip,
65      style,
66      omit,
67    }
68  
69    public String getFamily() {
70      return COMPONENT_FAMILY;
71    }
72  
73  
74    /**
75    Url to an image to display.
76  
77    */
78    public java.lang.String getImage() {
79      return (java.lang.String) getStateHelper().eval(PropertyKeys.image);
80    }
81  
82    public void setImage(java.lang.String image) {
83      getStateHelper().put(PropertyKeys.image, image);
84    }
85  
86    public org.apache.myfaces.tobago.context.Markup getMarkup() {
87      Object object = getStateHelper().eval(PropertyKeys.markup);
88      if (object != null) {
89        return Markup.valueOf(object);
90      }
91      return null;
92    }
93  
94    public void setMarkup(org.apache.myfaces.tobago.context.Markup markup) {
95      getStateHelper().put(PropertyKeys.markup, markup);
96    }
97  
98    /**
99    Link to an internal resource.
100    Resources will be processed by the resource management.
101    E. g. define help.html and it will be served help_es.html or help_de.html if available.
102    For JSF-Pages you have to set the jsfResource attribute.
103 
104   */
105   public java.lang.String getResource() {
106     return (java.lang.String) getStateHelper().eval(PropertyKeys.resource);
107   }
108 
109   public void setResource(java.lang.String resource) {
110     getStateHelper().put(PropertyKeys.resource, resource);
111   }
112 
113   /**
114   Link to an arbitrary URL, either an internal link or an external link.
115 
116    <dl>
117      <dt>internal absolute link</dt>
118      <dd>Starts with a slash '/' character. The context path will be added.
119          A session id will be added, if needed.</dd>
120      <dt>external link</dt>
121      <dd>Starts with protocol followed by a colon ':' character.
122          The link will not be modified.</dd>
123      <dt>internal relative link</dt>
124      <dd>Any other strings. A session id will be added, if needed.</dd>
125    </dl>
126 
127   */
128   public java.lang.String getLink() {
129     return (java.lang.String) getStateHelper().eval(PropertyKeys.link);
130   }
131 
132   public void setLink(java.lang.String link) {
133     getStateHelper().put(PropertyKeys.link, link);
134   }
135 
136   /**
137   Controls the navigation of the focus through the
138    input controls on a page with the Tab-Key.
139    The navigation starts from the element with
140    the lowest tabIndex value to the element with the highest value.
141    Elements that have identical tabIndex values should be navigated
142    in the order they appear in the character stream
143    Elements that are disabled or with a negative tabIndex
144    do not participate in the tabbing order.
145 
146   */
147   public java.lang.Integer getTabIndex() {
148     Number value  = (Number) getStateHelper().eval(PropertyKeys.tabIndex);
149     if (value != null) {
150       return value.intValue();
151     }
152     return null;
153   }
154 
155   public void setTabIndex(java.lang.Integer tabIndex) {
156     getStateHelper().put(PropertyKeys.tabIndex, tabIndex);
157   }
158 
159   /**
160   Text value to display as label.
161    If text contains an underscore the next character is used as accesskey (if configured so and possible).
162 
163   */
164   public java.lang.String getLabel() {
165     return (java.lang.String) getStateHelper().eval(PropertyKeys.label);
166   }
167 
168   public void setLabel(java.lang.String label) {
169     getStateHelper().put(PropertyKeys.label, label);
170   }
171 
172   /**
173   Specify, if the command calls an JSF-Action.
174    Useful to switch off the Double-Submit-Check and Waiting-Behavior.
175   <br>Default: <code>true</code>
176   */
177   public boolean isTransition() {
178     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.transition);
179     if (bool != null) {
180       return bool;
181     }
182     return true;
183   }
184 
185   public void setTransition(boolean transition) {
186     getStateHelper().put(PropertyKeys.transition, transition);
187   }
188 
189   /**
190   Name of a frame where the resource retrieved via this hyperlink is to be
191    displayed.
192 
193   */
194   public java.lang.String getTarget() {
195     return (java.lang.String) getStateHelper().eval(PropertyKeys.target);
196   }
197 
198   public void setTarget(java.lang.String target) {
199     getStateHelper().put(PropertyKeys.target, target);
200   }
201 
202   /**
203   <p>
204    Indicate the partially rendered components in a case of a submit.
205    </p>
206    <p>
207    The search depends on the number of prefixed colons in the relativeId:
208    </p>
209    <dl>
210      <dd>number of prefixed colons == 0</dd>
211      <dt>fully relative</dt>
212      <dd>number of prefixed colons == 1</dd>
213      <dt>absolute (still normal findComponent syntax)</dt>
214      <dd>number of prefixed colons == 2</dd>
215      <dt>search in the current naming container (same as 0 colons)</dt>
216      <dd>number of prefixed colons == 3</dd>
217      <dt>search in the parent naming container of the current naming container</dt>
218      <dd>number of prefixed colons &gt; 3</dd>
219      <dt>go to the next parent naming container for each additional colon</dt>
220    </dl>
221    <p>
222    If a literal is specified: to use more than one identifier the identifiers must be space delimited.
223    </p>
224    <p>
225    Using this in a UISheet or UITabGroup component this list indicates components to update when calling
226    internal AJAX requests like sort or paging commands.
227    Don't forget to add the sheet-id or tagGroup-id in that case, if needed.
228    </p>
229    <p>
230    You can also use
231 
232   */
233   public String[] getRenderedPartially() {
234     Object strArray = getStateHelper().eval(PropertyKeys.renderedPartially);
235     if (strArray != null) {
236       if (strArray instanceof String[]) {
237         return (String[]) strArray;
238       } else if (strArray instanceof String) {
239         String[] strings = StringUtils.split((String) strArray, ", ");
240         List<String> result = new ArrayList<String>(strings.length);
241         for (String string : strings) {
242           if (string.trim().length() != 0) {
243             result.add(string.trim());
244           }
245         }
246         return result.toArray(new String[result.size()]);
247       } else if (strArray == null) {
248         return org.apache.myfaces.tobago.internal.util.ArrayUtils.EMPTY_STRING_ARRAY;
249       } else {
250         return new String[]{strArray.toString()};
251       }
252     }
253     return org.apache.myfaces.tobago.internal.util.ArrayUtils.EMPTY_STRING_ARRAY;
254   }
255 
256   public void setRenderedPartially(String[] renderedPartially) {
257     getStateHelper().put(PropertyKeys.renderedPartially, renderedPartially);
258   }
259 
260   /**
261   If true the command is executed as default -- for example if the
262    user presses the enter key inside a related input field.
263   <br>Default: <code>false</code>
264   */
265   public boolean isDefaultCommand() {
266     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.defaultCommand);
267     if (bool != null) {
268       return bool;
269     }
270     return false;
271   }
272 
273   public void setDefaultCommand(boolean defaultCommand) {
274     getStateHelper().put(PropertyKeys.defaultCommand, defaultCommand);
275   }
276 
277   /**
278   Flag indicating that the resource referenced by the resource attribute is a jsf resource.
279    That means that the url has to be processed to change the prefix or suffix (e. g. *.jsf or
280    /faces/*). Default is false.
281   <br>Default: <code>false</code>
282   */
283   public boolean isJsfResource() {
284     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.jsfResource);
285     if (bool != null) {
286       return bool;
287     }
288     return false;
289   }
290 
291   public void setJsfResource(boolean jsfResource) {
292     getStateHelper().put(PropertyKeys.jsfResource, jsfResource);
293   }
294 
295   /**
296   The access key of this control.
297 
298   */
299   public java.lang.Character getAccessKey() {
300     return (java.lang.Character) getStateHelper().eval(PropertyKeys.accessKey);
301   }
302 
303   public void setAccessKey(java.lang.Character accessKey) {
304     getStateHelper().put(PropertyKeys.accessKey, accessKey);
305   }
306 
307   /**
308   Sets a CSS class in its parent, if the parent supports it.
309 
310    Which this feature it is possible to put a CSS class name into a component with the &lt;tc:style&gt; tag. Example:
311 
312    <pre>
313    &lt;tc:in&gt;
314      &lt;tc:style customClass="my-emphasized"/&gt;
315    &lt;/tc:in&gt;
316    </pre>
317 
318    One capability is, to used external CSS libs.
319    <br>
320    This feature should not be used imprudent.
321    Because it might be unstable against changes in the renderered HTML code.
322 
323   */
324   public org.apache.myfaces.tobago.renderkit.css.CustomClass getCustomClass() {
325     return (org.apache.myfaces.tobago.renderkit.css.CustomClass) getStateHelper().eval(PropertyKeys.customClass);
326   }
327 
328   public void setCustomClass(org.apache.myfaces.tobago.renderkit.css.CustomClass customClass) {
329     getStateHelper().put(PropertyKeys.customClass, customClass);
330   }
331 
332   /**
333   Text value to display as tooltip.
334 
335   */
336   public java.lang.String getTip() {
337     return (java.lang.String) getStateHelper().eval(PropertyKeys.tip);
338   }
339 
340   public void setTip(java.lang.String tip) {
341     getStateHelper().put(PropertyKeys.tip, tip);
342   }
343 
344   /**
345   For internal use. Used for rendering, if there is a child tag &lt;tc:style&gt;
346 
347   */
348   public org.apache.myfaces.tobago.renderkit.css.Style getStyle() {
349     return (org.apache.myfaces.tobago.renderkit.css.Style) getStateHelper().eval(PropertyKeys.style);
350   }
351 
352   public void setStyle(org.apache.myfaces.tobago.renderkit.css.Style style) {
353     getStateHelper().put(PropertyKeys.style, style);
354   }
355 
356   /**
357   Flag indicating that the action of this element, will not be executed from client side
358    (e. g. when the user clicks a button.
359    When setting this value to true, the action will not be executed by the Tobago, but it can executed
360    by JavaScript.
361    This attribute is useful, when you want to add JavaScript event handlers to commands manually.
362    In this case you usually don't want a submit with a full reload of the page.
363   <br>Default: <code>false</code>
364   */
365   public boolean isOmit() {
366     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.omit);
367     if (bool != null) {
368       return bool;
369     }
370     return false;
371   }
372 
373   public void setOmit(boolean omit) {
374     getStateHelper().put(PropertyKeys.omit, omit);
375   }
376 
377 
378 }