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.AbstractUIDatePicker;
25  import org.apache.myfaces.tobago.layout.Display;
26  import org.apache.myfaces.tobago.layout.Measure;
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 org.apache.myfaces.tobago.renderkit.MarginValues;
31  import org.apache.myfaces.tobago.renderkit.SpacingValues;
32  import org.apache.myfaces.tobago.renderkit.LayoutComponentRenderer;
33  import javax.el.ELException;
34  import javax.faces.FacesException;
35  import java.util.ArrayList;
36  import java.util.List;
37  import javax.el.MethodExpression;
38  import javax.el.ValueExpression;
39  
40  /** 
41   Renders a date picker.
42    The component needs a DateFormat Pattern from a converter. The converter
43    should be an instance of DateTimeConverter and return a valid pattern from
44    the method getPattern()
45    * UIComponent class, generated from template {@code component2.0.stg} with class
46    * {@link org.apache.myfaces.tobago.internal.taglib.component.DatePickerTagDeclaration}.
47   */
48  public class UIDatePicker
49      extends AbstractUIDatePicker implements SupportsMarkup {
50  
51    public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.DatePicker";
52  
53    public static final String COMPONENT_FAMILY = "javax.faces.Command";
54  
55    private org.apache.myfaces.tobago.context.Markup currentMarkup;
56  
57    enum PropertyKeys {
58      markup,
59      forComponent,
60      marginLeft,
61      link,
62      tabIndex,
63      minimumHeight,
64      tip,
65      height,
66      minimumWidth,
67      rowSpan,
68      left,
69      columnSpan,
70      maximumHeight,
71      top,
72      currentWidth,
73      marginTop,
74      marginRight,
75      width,
76      jsfResource,
77      resource,
78      preferredHeight,
79      currentHeight,
80      image,
81      display,
82      maximumWidth,
83      preferredWidth,
84      marginBottom,
85      verticalIndex,
86      renderedPartially,
87      onclick,
88      horizontalIndex,
89      disabled,
90    }
91  
92    public String getFamily() {
93      return COMPONENT_FAMILY;
94    }
95  
96  
97    public org.apache.myfaces.tobago.context.Markup getMarkup() {
98      Object object = getStateHelper().eval(PropertyKeys.markup);
99      if (object != null) {
100       return Markup.valueOf(object);
101     }
102     return null;
103   }
104 
105   public void setMarkup(org.apache.myfaces.tobago.context.Markup markup) {
106     getStateHelper().put(PropertyKeys.markup, markup);
107   }
108 
109   /**
110   Id of the component, this is related to.
111 
112   */
113   public java.lang.String getFor() {
114     return (java.lang.String) getStateHelper().eval(PropertyKeys.forComponent);
115   }
116 
117   public void setFor(java.lang.String forComponent) {
118     getStateHelper().put(PropertyKeys.forComponent, forComponent);
119   }
120 
121   public org.apache.myfaces.tobago.layout.Measure getMarginLeft() {
122     Object object = getStateHelper().eval(PropertyKeys.marginLeft);
123     if (object != null) {
124        return Measure.valueOf(object);
125     }
126     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginLeft(getFacesContext(), this) : Measure.ZERO;
127   }
128 
129   public void setMarginLeft(org.apache.myfaces.tobago.layout.Measure marginLeft) {
130     getStateHelper().put(PropertyKeys.marginLeft, marginLeft);
131   }
132 
133   public java.lang.String getLink() {
134     return (java.lang.String) getStateHelper().eval(PropertyKeys.link);
135   }
136 
137   public void setLink(java.lang.String link) {
138     getStateHelper().put(PropertyKeys.link, link);
139   }
140 
141   /**
142   Controls the navigation of the focus through the
143    input controls on a page with the Tab-Key.
144    The navigation starts from the element with
145    the lowest tabIndex value to the element with the highest value.
146    Elements that have identical tabIndex values should be navigated
147    in the order they appear in the character stream
148    Elements that are disabled or with a negative tabIndex
149    do not participate in the tabbing order.
150 
151   */
152   public java.lang.Integer getTabIndex() {
153     Number value  = (Number) getStateHelper().eval(PropertyKeys.tabIndex);
154     if (value != null) {
155       return value.intValue();
156     }
157     return null;
158   }
159 
160   public void setTabIndex(java.lang.Integer tabIndex) {
161     getStateHelper().put(PropertyKeys.tabIndex, tabIndex);
162   }
163 
164   public org.apache.myfaces.tobago.layout.Measure getMinimumHeight() {
165     Object object = getStateHelper().eval(PropertyKeys.minimumHeight);
166     if (object != null) {
167        return Measure.valueOf(object);
168     }
169     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMinimumHeight(getFacesContext(), this) : Measure.ZERO;
170   }
171 
172   public void setMinimumHeight(org.apache.myfaces.tobago.layout.Measure minimumHeight) {
173     getStateHelper().put(PropertyKeys.minimumHeight, minimumHeight);
174   }
175 
176   public java.lang.String getTip() {
177     return (java.lang.String) getStateHelper().eval(PropertyKeys.tip);
178   }
179 
180   public void setTip(java.lang.String tip) {
181     getStateHelper().put(PropertyKeys.tip, tip);
182   }
183 
184   /**
185   This value will usually be set by the layout manager.
186 
187   */
188   public org.apache.myfaces.tobago.layout.Measure getHeight() {
189     Object object = getStateHelper().eval(PropertyKeys.height);
190     if (object != null) {
191        return Measure.valueOf(object);
192     }
193     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getHeight(getFacesContext(), this) : Measure.ZERO;
194   }
195 
196   public void setHeight(org.apache.myfaces.tobago.layout.Measure height) {
197     getStateHelper().put(PropertyKeys.height, height);
198   }
199 
200   public org.apache.myfaces.tobago.layout.Measure getMinimumWidth() {
201     Object object = getStateHelper().eval(PropertyKeys.minimumWidth);
202     if (object != null) {
203        return Measure.valueOf(object);
204     }
205     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMinimumWidth(getFacesContext(), this) : Measure.ZERO;
206   }
207 
208   public void setMinimumWidth(org.apache.myfaces.tobago.layout.Measure minimumWidth) {
209     getStateHelper().put(PropertyKeys.minimumWidth, minimumWidth);
210   }
211 
212   public java.lang.Integer getRowSpan() {
213     Number value  = (Number) getStateHelper().eval(PropertyKeys.rowSpan);
214     if (value != null) {
215       return value.intValue();
216     }
217     return 1;
218   }
219 
220   public void setRowSpan(java.lang.Integer rowSpan) {
221     getStateHelper().put(PropertyKeys.rowSpan, rowSpan);
222   }
223 
224   /**
225   This value will usually be set by the layout manager.
226 
227   */
228   public org.apache.myfaces.tobago.layout.Measure getLeft() {
229     Object object = getStateHelper().eval(PropertyKeys.left);
230     if (object != null) {
231        return Measure.valueOf(object);
232     }
233     return null;
234   }
235 
236   public void setLeft(org.apache.myfaces.tobago.layout.Measure left) {
237     getStateHelper().put(PropertyKeys.left, left);
238   }
239 
240   public java.lang.Integer getColumnSpan() {
241     Number value  = (Number) getStateHelper().eval(PropertyKeys.columnSpan);
242     if (value != null) {
243       return value.intValue();
244     }
245     return 1;
246   }
247 
248   public void setColumnSpan(java.lang.Integer columnSpan) {
249     getStateHelper().put(PropertyKeys.columnSpan, columnSpan);
250   }
251 
252   public org.apache.myfaces.tobago.layout.Measure getMaximumHeight() {
253     Object object = getStateHelper().eval(PropertyKeys.maximumHeight);
254     if (object != null) {
255        return Measure.valueOf(object);
256     }
257     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMaximumHeight(getFacesContext(), this) : Measure.ZERO;
258   }
259 
260   public void setMaximumHeight(org.apache.myfaces.tobago.layout.Measure maximumHeight) {
261     getStateHelper().put(PropertyKeys.maximumHeight, maximumHeight);
262   }
263 
264   /**
265   This value will usually be set by the layout manager.
266 
267   */
268   public org.apache.myfaces.tobago.layout.Measure getTop() {
269     Object object = getStateHelper().eval(PropertyKeys.top);
270     if (object != null) {
271        return Measure.valueOf(object);
272     }
273     return null;
274   }
275 
276   public void setTop(org.apache.myfaces.tobago.layout.Measure top) {
277     getStateHelper().put(PropertyKeys.top, top);
278   }
279 
280   /**
281   This value will usually be set by the layout manager. It holds the current width computed by the layout manager.
282 
283   */
284   public org.apache.myfaces.tobago.layout.Measure getCurrentWidth() {
285     Object object = getStateHelper().eval(PropertyKeys.currentWidth);
286     if (object != null) {
287        return Measure.valueOf(object);
288     }
289     return getWidth();
290   }
291 
292   public void setCurrentWidth(org.apache.myfaces.tobago.layout.Measure currentWidth) {
293     getStateHelper().put(PropertyKeys.currentWidth, currentWidth);
294   }
295 
296   public org.apache.myfaces.tobago.layout.Measure getMarginTop() {
297     Object object = getStateHelper().eval(PropertyKeys.marginTop);
298     if (object != null) {
299        return Measure.valueOf(object);
300     }
301     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginTop(getFacesContext(), this) : Measure.ZERO;
302   }
303 
304   public void setMarginTop(org.apache.myfaces.tobago.layout.Measure marginTop) {
305     getStateHelper().put(PropertyKeys.marginTop, marginTop);
306   }
307 
308   public org.apache.myfaces.tobago.layout.Measure getMarginRight() {
309     Object object = getStateHelper().eval(PropertyKeys.marginRight);
310     if (object != null) {
311        return Measure.valueOf(object);
312     }
313     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginRight(getFacesContext(), this) : Measure.ZERO;
314   }
315 
316   public void setMarginRight(org.apache.myfaces.tobago.layout.Measure marginRight) {
317     getStateHelper().put(PropertyKeys.marginRight, marginRight);
318   }
319 
320   /**
321   This value will usually be set by the layout manager.
322 
323   */
324   public org.apache.myfaces.tobago.layout.Measure getWidth() {
325     Object object = getStateHelper().eval(PropertyKeys.width);
326     if (object != null) {
327        return Measure.valueOf(object);
328     }
329     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getWidth(getFacesContext(), this) : Measure.ZERO;
330   }
331 
332   public void setWidth(org.apache.myfaces.tobago.layout.Measure width) {
333     getStateHelper().put(PropertyKeys.width, width);
334   }
335 
336   public boolean isJsfResource() {
337     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.jsfResource);
338     if (bool != null) {
339       return bool;
340     }
341     return false;
342   }
343 
344   public void setJsfResource(boolean jsfResource) {
345     getStateHelper().put(PropertyKeys.jsfResource, jsfResource);
346   }
347 
348   public java.lang.String getResource() {
349     return (java.lang.String) getStateHelper().eval(PropertyKeys.resource);
350   }
351 
352   public void setResource(java.lang.String resource) {
353     getStateHelper().put(PropertyKeys.resource, resource);
354   }
355 
356   public org.apache.myfaces.tobago.layout.Measure getPreferredHeight() {
357     Object object = getStateHelper().eval(PropertyKeys.preferredHeight);
358     if (object != null) {
359        return Measure.valueOf(object);
360     }
361     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getPreferredHeight(getFacesContext(), this) : Measure.ZERO;
362   }
363 
364   public void setPreferredHeight(org.apache.myfaces.tobago.layout.Measure preferredHeight) {
365     getStateHelper().put(PropertyKeys.preferredHeight, preferredHeight);
366   }
367 
368   /**
369   This value will usually be set by the layout manager. It holds the current height computed by the layout manager.
370 
371   */
372   public org.apache.myfaces.tobago.layout.Measure getCurrentHeight() {
373     Object object = getStateHelper().eval(PropertyKeys.currentHeight);
374     if (object != null) {
375        return Measure.valueOf(object);
376     }
377     return getHeight();
378   }
379 
380   public void setCurrentHeight(org.apache.myfaces.tobago.layout.Measure currentHeight) {
381     getStateHelper().put(PropertyKeys.currentHeight, currentHeight);
382   }
383 
384   public java.lang.String getImage() {
385     return (java.lang.String) getStateHelper().eval(PropertyKeys.image);
386   }
387 
388   public void setImage(java.lang.String image) {
389     getStateHelper().put(PropertyKeys.image, image);
390   }
391 
392   /**
393   This attribute is for internal use only.
394 
395   */
396   public org.apache.myfaces.tobago.layout.Display getDisplay() {
397     return (org.apache.myfaces.tobago.layout.Display) getStateHelper().eval(PropertyKeys.display);
398   }
399 
400   public void setDisplay(org.apache.myfaces.tobago.layout.Display display) {
401     getStateHelper().put(PropertyKeys.display, display);
402   }
403 
404   public org.apache.myfaces.tobago.layout.Measure getMaximumWidth() {
405     Object object = getStateHelper().eval(PropertyKeys.maximumWidth);
406     if (object != null) {
407        return Measure.valueOf(object);
408     }
409     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMaximumWidth(getFacesContext(), this) : Measure.ZERO;
410   }
411 
412   public void setMaximumWidth(org.apache.myfaces.tobago.layout.Measure maximumWidth) {
413     getStateHelper().put(PropertyKeys.maximumWidth, maximumWidth);
414   }
415 
416   public org.apache.myfaces.tobago.layout.Measure getPreferredWidth() {
417     Object object = getStateHelper().eval(PropertyKeys.preferredWidth);
418     if (object != null) {
419        return Measure.valueOf(object);
420     }
421     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getPreferredWidth(getFacesContext(), this) : Measure.ZERO;
422   }
423 
424   public void setPreferredWidth(org.apache.myfaces.tobago.layout.Measure preferredWidth) {
425     getStateHelper().put(PropertyKeys.preferredWidth, preferredWidth);
426   }
427 
428   public org.apache.myfaces.tobago.layout.Measure getMarginBottom() {
429     Object object = getStateHelper().eval(PropertyKeys.marginBottom);
430     if (object != null) {
431        return Measure.valueOf(object);
432     }
433     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginBottom(getFacesContext(), this) : Measure.ZERO;
434   }
435 
436   public void setMarginBottom(org.apache.myfaces.tobago.layout.Measure marginBottom) {
437     getStateHelper().put(PropertyKeys.marginBottom, marginBottom);
438   }
439 
440   /**
441   This attribute is for internal use only.
442 
443   */
444   public java.lang.Integer getVerticalIndex() {
445     Number value  = (Number) getStateHelper().eval(PropertyKeys.verticalIndex);
446     if (value != null) {
447       return value.intValue();
448     }
449     return null;
450   }
451 
452   public void setVerticalIndex(java.lang.Integer verticalIndex) {
453     getStateHelper().put(PropertyKeys.verticalIndex, verticalIndex);
454   }
455 
456   public String[] getRenderedPartially() {
457     Object strArray = getStateHelper().eval(PropertyKeys.renderedPartially);
458     if (strArray != null) {
459       if (strArray instanceof String[]) {
460         return (String[]) strArray;
461       } else if (strArray instanceof String) {
462         String[] strings = StringUtils.split((String) strArray, ", ");
463         List<String> result = new ArrayList<String>(strings.length);
464         for (String string : strings) {
465           if (string.trim().length() != 0) {
466             result.add(string.trim());
467           }
468         }
469         return result.toArray(new String[result.size()]);
470       } else if (strArray == null) {
471         return org.apache.myfaces.tobago.internal.util.ArrayUtils.EMPTY_STRING_ARRAY;
472       } else {
473         return new String[]{strArray.toString()};
474       }
475     }
476     return org.apache.myfaces.tobago.internal.util.ArrayUtils.EMPTY_STRING_ARRAY;
477   }
478 
479   public void setRenderedPartially(String[] renderedPartially) {
480     getStateHelper().put(PropertyKeys.renderedPartially, renderedPartially);
481   }
482 
483   public org.apache.myfaces.tobago.context.Markup getCurrentMarkup() {
484     if (currentMarkup != null) {
485       return currentMarkup;
486     }
487     return null;
488   }
489 
490   public void setCurrentMarkup(org.apache.myfaces.tobago.context.Markup currentMarkup) {
491     this.currentMarkup = currentMarkup;
492   }
493 
494   public java.lang.String getOnclick() {
495     return (java.lang.String) getStateHelper().eval(PropertyKeys.onclick);
496   }
497 
498   public void setOnclick(java.lang.String onclick) {
499     getStateHelper().put(PropertyKeys.onclick, onclick);
500   }
501 
502   /**
503   This attribute is for internal use only.
504 
505   */
506   public java.lang.Integer getHorizontalIndex() {
507     Number value  = (Number) getStateHelper().eval(PropertyKeys.horizontalIndex);
508     if (value != null) {
509       return value.intValue();
510     }
511     return null;
512   }
513 
514   public void setHorizontalIndex(java.lang.Integer horizontalIndex) {
515     getStateHelper().put(PropertyKeys.horizontalIndex, horizontalIndex);
516   }
517 
518   public boolean isDisabled() {
519     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.disabled);
520     if (bool != null) {
521       return bool;
522     }
523     return false;
524   }
525 
526   public void setDisabled(boolean disabled) {
527     getStateHelper().put(PropertyKeys.disabled, disabled);
528   }
529 
530   public Object saveState(FacesContext context) {
531     currentMarkup = null;
532     return super.saveState(context);
533   }
534 
535 
536 }