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.el.ELException;
30  import javax.faces.FacesException;
31  import java.util.Arrays;
32  import java.util.ArrayList;
33  import java.util.Collection;
34  import java.util.List;
35  import javax.el.MethodExpression;
36  import javax.el.ValueExpression;
37  
38  /** 
39   Renders a date input field.
40    <p>
41    For a time input field set you'll need to set the &lt;f:convertDateTime type="time"&gt; inside the &lt;tc:date&gt;.
42    <p>
43    If there is no converter given, a default instance of {
44    * UIComponent class, generated from template {@code component.stg} with class
45    * {@link org.apache.myfaces.tobago.internal.taglib.component.DateTagDeclaration}.
46   */
47  public class UIDate
48      extends AbstractUIDate implements Visual {
49  
50    public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.Date";
51  
52    public static final String COMPONENT_FAMILY = "javax.faces.Input";
53  
54    private static final Collection<String> EVENT_NAMES = Arrays.asList("change", "click", "dblclick", "focus", "blur");
55  
56    @Override
57    public Collection<String> getEventNames() {
58      return EVENT_NAMES;
59    }
60  
61    @Override
62    public String getDefaultEventName() {
63      return "change";
64    }
65  
66  
67    enum PropertyKeys {
68      markup,
69      labelLayout,
70      focus,
71      tabIndex,
72      label,
73      readonly,
74      accessKey,
75      customClass,
76      disabled,
77      tip,
78      placeholder,
79    }
80  
81    public String getFamily() {
82      return COMPONENT_FAMILY;
83    }
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    Defines the position of the label relative to the field.
100    The default is flexLeft, if the label is set, or none, if the label isn't set.
101    Set to 'skip' to avoid surrounding label container.
102    Hint for tc:out: set also compact=true to render only text (without html tags).
103 
104   */
105   public org.apache.myfaces.tobago.component.LabelLayout getLabelLayout() {
106     org.apache.myfaces.tobago.component.LabelLayout labelLayout = (org.apache.myfaces.tobago.component.LabelLayout) getStateHelper().eval(PropertyKeys.labelLayout);
107     if (labelLayout != null) {
108       return labelLayout;
109     }
110     return getLabel() != null ? org.apache.myfaces.tobago.component.LabelLayout.flexLeft : org.apache.myfaces.tobago.component.LabelLayout.none;
111   }
112 
113   public void setLabelLayout(org.apache.myfaces.tobago.component.LabelLayout labelLayout) {
114     getStateHelper().put(PropertyKeys.labelLayout, labelLayout);
115   }
116 
117   /**
118   Flag indicating this component should receive the focus.
119   <br>Default: <code>false</code>
120   */
121   public boolean isFocus() {
122     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.focus);
123     if (bool != null) {
124       return bool;
125     }
126     return false;
127   }
128 
129   public void setFocus(boolean focus) {
130     getStateHelper().put(PropertyKeys.focus, focus);
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   A localized user presentable label for this component.
158 
159   */
160   public java.lang.String getLabel() {
161     return (java.lang.String) getStateHelper().eval(PropertyKeys.label);
162   }
163 
164   public void setLabel(java.lang.String label) {
165     getStateHelper().put(PropertyKeys.label, label);
166   }
167 
168   /**
169   Flag indicating that this component will prohibit changes by the user.
170   <br>Default: <code>false</code>
171   */
172   public boolean isReadonly() {
173     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.readonly);
174     if (bool != null) {
175       return bool;
176     }
177     return false;
178   }
179 
180   public void setReadonly(boolean readonly) {
181     getStateHelper().put(PropertyKeys.readonly, readonly);
182   }
183 
184   /**
185   The access key of this control.
186 
187   */
188   public java.lang.Character getAccessKey() {
189     return (java.lang.Character) getStateHelper().eval(PropertyKeys.accessKey);
190   }
191 
192   public void setAccessKey(java.lang.Character accessKey) {
193     getStateHelper().put(PropertyKeys.accessKey, accessKey);
194   }
195 
196   /**
197   Sets a CSS class in its parent, if the parent supports it.
198 
199    Which this feature it is possible to put a CSS class name into a component with the &lt;tc:style&gt; tag. Example:
200 
201    <pre>
202    &lt;tc:in&gt;
203      &lt;tc:style customClass="my-emphasized"/&gt;
204    &lt;/tc:in&gt;
205    </pre>
206 
207    One capability is, to used external CSS libs.
208    <br>
209    This feature should not be used imprudent.
210    Because it might be unstable against changes in the renderered HTML code.
211 
212   */
213   public org.apache.myfaces.tobago.renderkit.css.CustomClass getCustomClass() {
214     return (org.apache.myfaces.tobago.renderkit.css.CustomClass) getStateHelper().eval(PropertyKeys.customClass);
215   }
216 
217   public void setCustomClass(org.apache.myfaces.tobago.renderkit.css.CustomClass customClass) {
218     getStateHelper().put(PropertyKeys.customClass, customClass);
219   }
220 
221   /**
222   Flag indicating that this element is disabled.
223   <br>Default: <code>false</code>
224   */
225   public boolean isDisabled() {
226     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.disabled);
227     if (bool != null) {
228       return bool;
229     }
230     return false;
231   }
232 
233   public void setDisabled(boolean disabled) {
234     getStateHelper().put(PropertyKeys.disabled, disabled);
235   }
236 
237   /**
238   Text value to display as tooltip.
239 
240   */
241   public java.lang.String getTip() {
242     return (java.lang.String) getStateHelper().eval(PropertyKeys.tip);
243   }
244 
245   public void setTip(java.lang.String tip) {
246     getStateHelper().put(PropertyKeys.tip, tip);
247   }
248 
249   /**
250   <p>
251    Displays a short text in the input field, that describes the meaning of this field.
252    This is part of HTML 5, the theme should emulate the behaviour, when the browser doesn't support it.
253    </p>
254    <p>
255    The text will not be displayed, when the input field is readonly or disabled.
256    </p>
257 
258   */
259   public java.lang.String getPlaceholder() {
260     return (java.lang.String) getStateHelper().eval(PropertyKeys.placeholder);
261   }
262 
263   public void setPlaceholder(java.lang.String placeholder) {
264     getStateHelper().put(PropertyKeys.placeholder, placeholder);
265   }
266 
267 
268 }