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.AbstractUIFile;
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   <p>
42    Renders a file input field.
43    </p>
44    <p>
45    For content constraints please use <a href="validateFileItem.html">tc:validateFileItem</a>.
46    </p>
47    * UIComponent class, generated from template {@code component.stg} with class
48    * {@link org.apache.myfaces.tobago.internal.taglib.component.FileTagDeclaration}.
49   */
50  @Generated("component.stg")
51  public class UIFile
52      extends AbstractUIFile  {
53  
54    public static final String COMPONENT_TYPE = Tags.file.componentType();
55  
56    public static final String COMPONENT_FAMILY = "javax.faces.Input";
57  
58    private static final Collection<String> EVENT_NAMES = Arrays.asList("change", "click", "dblclick", "focus", "blur");
59  
60    @Override
61    public Collection<String> getEventNames() {
62      return EVENT_NAMES;
63    }
64  
65    @Override
66    public String getDefaultEventName() {
67      return "change";
68    }
69  
70  
71    enum PropertyKeys {
72      markup,
73      labelLayout,
74      multiple,
75      focus,
76      tabIndex,
77      label,
78      help,
79      readonly,
80      accessKey,
81      customClass,
82      disabled,
83      tip,
84      placeholder,
85    }
86  
87    public String getFamily() {
88      return COMPONENT_FAMILY;
89    }
90  
91  
92    public org.apache.myfaces.tobago.context.Markup getMarkup() {
93      Object object = getStateHelper().eval(PropertyKeys.markup);
94      if (object != null) {
95        return Markup.valueOf(object);
96      }
97      return null;
98    }
99  
100   public void setMarkup(org.apache.myfaces.tobago.context.Markup markup) {
101     getStateHelper().put(PropertyKeys.markup, markup);
102   }
103 
104   /**
105   Defines the position of the label relative to the field.
106    The default is flexLeft, if the label is set, or none, if the label isn't set.
107    Set to 'skip' to avoid surrounding label container.
108    Hint for tc:out: set also compact=true to render only text (without html tags).
109 
110   */
111   public org.apache.myfaces.tobago.component.LabelLayout getLabelLayout() {
112     org.apache.myfaces.tobago.component.LabelLayout labelLayout = (org.apache.myfaces.tobago.component.LabelLayout) getStateHelper().eval(PropertyKeys.labelLayout);
113     if (labelLayout != null) {
114       return labelLayout;
115     }
116     return getLabel() != null ? org.apache.myfaces.tobago.component.LabelLayout.flexLeft : org.apache.myfaces.tobago.component.LabelLayout.none;
117   }
118 
119   public void setLabelLayout(org.apache.myfaces.tobago.component.LabelLayout labelLayout) {
120     getStateHelper().put(PropertyKeys.labelLayout, labelLayout);
121   }
122 
123   public boolean isMultiple() {
124     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.multiple);
125     if (bool != null) {
126       return bool;
127     }
128     return false;
129   }
130 
131   public void setMultiple(boolean multiple) {
132     getStateHelper().put(PropertyKeys.multiple, multiple);
133   }
134 
135   /**
136   Flag indicating this component should receive the focus.
137   <br>Default: <code>false</code>
138   */
139   public boolean isFocus() {
140     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.focus);
141     if (bool != null) {
142       return bool;
143     }
144     return false;
145   }
146 
147   public void setFocus(boolean focus) {
148     getStateHelper().put(PropertyKeys.focus, focus);
149   }
150 
151   /**
152   Controls the navigation of the focus through the
153    input controls on a page with the Tab-Key.
154    The navigation starts from the element with
155    the lowest tabIndex value to the element with the highest value.
156    Elements that have identical tabIndex values should be navigated
157    in the order they appear in the character stream
158    Elements that are disabled or with a negative tabIndex
159    do not participate in the tabbing order.
160 
161   */
162   public java.lang.Integer getTabIndex() {
163     Number value  = (Number) getStateHelper().eval(PropertyKeys.tabIndex);
164     if (value != null) {
165       return value.intValue();
166     }
167     return null;
168   }
169 
170   public void setTabIndex(java.lang.Integer tabIndex) {
171     getStateHelper().put(PropertyKeys.tabIndex, tabIndex);
172   }
173 
174   /**
175   A localized user presentable label for this component.
176 
177   */
178   public java.lang.String getLabel() {
179     return (java.lang.String) getStateHelper().eval(PropertyKeys.label);
180   }
181 
182   public void setLabel(java.lang.String label) {
183     getStateHelper().put(PropertyKeys.label, label);
184   }
185 
186   /**
187   Text value to display as a help.
188 
189   */
190   public java.lang.String getHelp() {
191     return (java.lang.String) getStateHelper().eval(PropertyKeys.help);
192   }
193 
194   public void setHelp(java.lang.String help) {
195     getStateHelper().put(PropertyKeys.help, help);
196   }
197 
198   /**
199   Flag indicating that this component will prohibit changes by the user.
200   <br>Default: <code>false</code>
201   */
202   public boolean isReadonly() {
203     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.readonly);
204     if (bool != null) {
205       return bool;
206     }
207     return false;
208   }
209 
210   public void setReadonly(boolean readonly) {
211     getStateHelper().put(PropertyKeys.readonly, readonly);
212   }
213 
214   /**
215   The access key of this control.
216 
217   */
218   public java.lang.Character getAccessKey() {
219     return (java.lang.Character) getStateHelper().eval(PropertyKeys.accessKey);
220   }
221 
222   public void setAccessKey(java.lang.Character accessKey) {
223     getStateHelper().put(PropertyKeys.accessKey, accessKey);
224   }
225 
226   /**
227   Sets a CSS class in its parent, if the parent supports it.
228 
229    Which this feature it is possible to put a CSS class name into a component with the &lt;tc:style&gt; tag. Example:
230 
231    <pre>
232    &lt;tc:in&gt;
233      &lt;tc:style customClass="my-emphasized"/&gt;
234    &lt;/tc:in&gt;
235    </pre>
236 
237    One capability is, to used external CSS libs.
238    <br>
239    This feature should not be used imprudent.
240    Because it might be unstable against changes in the renderered HTML code.
241 
242   */
243   public org.apache.myfaces.tobago.renderkit.css.CustomClass getCustomClass() {
244     return (org.apache.myfaces.tobago.renderkit.css.CustomClass) getStateHelper().eval(PropertyKeys.customClass);
245   }
246 
247   public void setCustomClass(org.apache.myfaces.tobago.renderkit.css.CustomClass customClass) {
248     getStateHelper().put(PropertyKeys.customClass, customClass);
249   }
250 
251   /**
252   Flag indicating that this element is disabled.
253   <br>Default: <code>false</code>
254   */
255   public boolean isDisabled() {
256     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.disabled);
257     if (bool != null) {
258       return bool;
259     }
260     return false;
261   }
262 
263   public void setDisabled(boolean disabled) {
264     getStateHelper().put(PropertyKeys.disabled, disabled);
265   }
266 
267   /**
268   Text value to display as tooltip.
269 
270   */
271   public java.lang.String getTip() {
272     return (java.lang.String) getStateHelper().eval(PropertyKeys.tip);
273   }
274 
275   public void setTip(java.lang.String tip) {
276     getStateHelper().put(PropertyKeys.tip, tip);
277   }
278 
279   /**
280   <p>
281    Displays a short text in the input field, that describes the meaning of this field.
282    </p>
283 
284   */
285   public java.lang.String getPlaceholder() {
286     return (java.lang.String) getStateHelper().eval(PropertyKeys.placeholder);
287   }
288 
289   public void setPlaceholder(java.lang.String placeholder) {
290     getStateHelper().put(PropertyKeys.placeholder, placeholder);
291   }
292 
293 
294   @Override
295   public void restoreState(FacesContext context, Object state) {
296     // FIXME HACK for mojarra SystemEventListener state restoring bug
297     pushComponentToEL(context, this);
298     super.restoreState(context, state);
299     popComponentFromEL(context);
300   }
301 
302 }