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