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