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.AbstractUISelectOneChoice;
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   Render a single selection dropdown list.
42    * UIComponent class, generated from template {@code component2.0.stg} with class
43    * {@link org.apache.myfaces.tobago.internal.taglib.component.SelectOneChoiceTagDeclaration}.
44   */
45  public class UISelectOneChoice
46      extends AbstractUISelectOneChoice implements SupportsMarkup {
47  
48    public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.SelectOneChoice";
49  
50    public static final String COMPONENT_FAMILY = "javax.faces.SelectOne";
51  
52    private org.apache.myfaces.tobago.context.Markup currentMarkup;
53  
54    enum PropertyKeys {
55      accessKey,
56      markup,
57      marginLeft,
58      labelWithAccessKey,
59      tabIndex,
60      minimumHeight,
61      tip,
62      height,
63      minimumWidth,
64      inline,
65      rowSpan,
66      focus,
67      left,
68      columnSpan,
69      top,
70      maximumHeight,
71      currentWidth,
72      marginTop,
73      width,
74      marginRight,
75      currentHeight,
76      preferredHeight,
77      label,
78      display,
79      maximumWidth,
80      onchange,
81      preferredWidth,
82      marginBottom,
83      verticalIndex,
84      horizontalIndex,
85      readonly,
86      disabled,
87    }
88  
89    public String getFamily() {
90      return COMPONENT_FAMILY;
91    }
92  
93  
94    /**
95    Deprecated! Has not longer any function.
96  
97    @deprecated*/
98    @Deprecated
99    public java.lang.Character getAccessKey() {
100     return (java.lang.Character) getStateHelper().eval(PropertyKeys.accessKey);
101   }
102 
103   @Deprecated
104   public void setAccessKey(java.lang.Character accessKey) {
105       Deprecation.LOG.error("The attribute 'accessKey' of 'UISelectOneChoice' is deprecated. "
106           + "Please refer the documentation for further information.");
107     getStateHelper().put(PropertyKeys.accessKey, accessKey);
108   }
109 
110   public org.apache.myfaces.tobago.context.Markup getMarkup() {
111     Object object = getStateHelper().eval(PropertyKeys.markup);
112     if (object != null) {
113       return Markup.valueOf(object);
114     }
115     return null;
116   }
117 
118   public void setMarkup(org.apache.myfaces.tobago.context.Markup markup) {
119     getStateHelper().put(PropertyKeys.markup, markup);
120   }
121 
122   public org.apache.myfaces.tobago.layout.Measure getMarginLeft() {
123     Object object = getStateHelper().eval(PropertyKeys.marginLeft);
124     if (object != null) {
125        return Measure.valueOf(object);
126     }
127     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginLeft(getFacesContext(), this) : Measure.ZERO;
128   }
129 
130   public void setMarginLeft(org.apache.myfaces.tobago.layout.Measure marginLeft) {
131     getStateHelper().put(PropertyKeys.marginLeft, marginLeft);
132   }
133 
134   /**
135   Deprecated! Use 'label' instead.
136    Text value to display as label.
137    If text contains an underscore the next character overwrites 'accesskey'.
138 
139   @deprecated*/
140   @Deprecated
141   public java.lang.String getLabelWithAccessKey() {
142     return (java.lang.String) getStateHelper().eval(PropertyKeys.labelWithAccessKey);
143   }
144 
145   @Deprecated
146   public void setLabelWithAccessKey(java.lang.String labelWithAccessKey) {
147       Deprecation.LOG.error("The attribute 'labelWithAccessKey' of 'UISelectOneChoice' is deprecated. "
148           + "Please refer the documentation for further information.");
149     getStateHelper().put(PropertyKeys.labelWithAccessKey, labelWithAccessKey);
150   }
151 
152   /**
153   Controls the navigation of the focus through the
154    input controls on a page with the Tab-Key.
155    The navigation starts from the element with
156    the lowest tabIndex value to the element with the highest value.
157    Elements that have identical tabIndex values should be navigated
158    in the order they appear in the character stream
159    Elements that are disabled or with a negative tabIndex
160    do not participate in the tabbing order.
161 
162   */
163   public java.lang.Integer getTabIndex() {
164     Number value  = (Number) getStateHelper().eval(PropertyKeys.tabIndex);
165     if (value != null) {
166       return value.intValue();
167     }
168     return null;
169   }
170 
171   public void setTabIndex(java.lang.Integer tabIndex) {
172     getStateHelper().put(PropertyKeys.tabIndex, tabIndex);
173   }
174 
175   public org.apache.myfaces.tobago.layout.Measure getMinimumHeight() {
176     Object object = getStateHelper().eval(PropertyKeys.minimumHeight);
177     if (object != null) {
178        return Measure.valueOf(object);
179     }
180     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMinimumHeight(getFacesContext(), this) : Measure.ZERO;
181   }
182 
183   public void setMinimumHeight(org.apache.myfaces.tobago.layout.Measure minimumHeight) {
184     getStateHelper().put(PropertyKeys.minimumHeight, minimumHeight);
185   }
186 
187   /**
188   Text value to display as tooltip.
189 
190   */
191   public java.lang.String getTip() {
192     return (java.lang.String) getStateHelper().eval(PropertyKeys.tip);
193   }
194 
195   public void setTip(java.lang.String tip) {
196     getStateHelper().put(PropertyKeys.tip, tip);
197   }
198 
199   /**
200   This value will usually be set by the layout manager.
201 
202   */
203   public org.apache.myfaces.tobago.layout.Measure getHeight() {
204     Object object = getStateHelper().eval(PropertyKeys.height);
205     if (object != null) {
206        return Measure.valueOf(object);
207     }
208     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getHeight(getFacesContext(), this) : Measure.ZERO;
209   }
210 
211   public void setHeight(org.apache.myfaces.tobago.layout.Measure height) {
212     getStateHelper().put(PropertyKeys.height, height);
213   }
214 
215   public org.apache.myfaces.tobago.layout.Measure getMinimumWidth() {
216     Object object = getStateHelper().eval(PropertyKeys.minimumWidth);
217     if (object != null) {
218        return Measure.valueOf(object);
219     }
220     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMinimumWidth(getFacesContext(), this) : Measure.ZERO;
221   }
222 
223   public void setMinimumWidth(org.apache.myfaces.tobago.layout.Measure minimumWidth) {
224     getStateHelper().put(PropertyKeys.minimumWidth, minimumWidth);
225   }
226 
227   /**
228   Flag indicating this component should rendered as an inline element.
229   <br />Default: <code>false</code>
230   @deprecated*/
231   @Deprecated
232   public boolean isInline() {
233     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.inline);
234     if (bool != null) {
235       return bool;
236     }
237     return false;
238   }
239 
240   @Deprecated
241   public void setInline(boolean inline) {
242       Deprecation.LOG.error("The attribute 'inline' of 'UISelectOneChoice' is deprecated. "
243           + "Please refer the documentation for further information.");
244     getStateHelper().put(PropertyKeys.inline, inline);
245   }
246 
247   public java.lang.Integer getRowSpan() {
248     Number value  = (Number) getStateHelper().eval(PropertyKeys.rowSpan);
249     if (value != null) {
250       return value.intValue();
251     }
252     return 1;
253   }
254 
255   public void setRowSpan(java.lang.Integer rowSpan) {
256     getStateHelper().put(PropertyKeys.rowSpan, rowSpan);
257   }
258 
259   /**
260   Flag indicating this component should receive the focus.
261   <br />Default: <code>false</code>
262   */
263   public boolean isFocus() {
264     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.focus);
265     if (bool != null) {
266       return bool;
267     }
268     return false;
269   }
270 
271   public void setFocus(boolean focus) {
272     getStateHelper().put(PropertyKeys.focus, focus);
273   }
274 
275   /**
276   This value will usually be set by the layout manager.
277 
278   */
279   public org.apache.myfaces.tobago.layout.Measure getLeft() {
280     Object object = getStateHelper().eval(PropertyKeys.left);
281     if (object != null) {
282        return Measure.valueOf(object);
283     }
284     return null;
285   }
286 
287   public void setLeft(org.apache.myfaces.tobago.layout.Measure left) {
288     getStateHelper().put(PropertyKeys.left, left);
289   }
290 
291   public java.lang.Integer getColumnSpan() {
292     Number value  = (Number) getStateHelper().eval(PropertyKeys.columnSpan);
293     if (value != null) {
294       return value.intValue();
295     }
296     return 1;
297   }
298 
299   public void setColumnSpan(java.lang.Integer columnSpan) {
300     getStateHelper().put(PropertyKeys.columnSpan, columnSpan);
301   }
302 
303   /**
304   This value will usually be set by the layout manager.
305 
306   */
307   public org.apache.myfaces.tobago.layout.Measure getTop() {
308     Object object = getStateHelper().eval(PropertyKeys.top);
309     if (object != null) {
310        return Measure.valueOf(object);
311     }
312     return null;
313   }
314 
315   public void setTop(org.apache.myfaces.tobago.layout.Measure top) {
316     getStateHelper().put(PropertyKeys.top, top);
317   }
318 
319   public org.apache.myfaces.tobago.layout.Measure getMaximumHeight() {
320     Object object = getStateHelper().eval(PropertyKeys.maximumHeight);
321     if (object != null) {
322        return Measure.valueOf(object);
323     }
324     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMaximumHeight(getFacesContext(), this) : Measure.ZERO;
325   }
326 
327   public void setMaximumHeight(org.apache.myfaces.tobago.layout.Measure maximumHeight) {
328     getStateHelper().put(PropertyKeys.maximumHeight, maximumHeight);
329   }
330 
331   /**
332   This value will usually be set by the layout manager. It holds the current width computed by the layout manager.
333 
334   */
335   public org.apache.myfaces.tobago.layout.Measure getCurrentWidth() {
336     Object object = getStateHelper().eval(PropertyKeys.currentWidth);
337     if (object != null) {
338        return Measure.valueOf(object);
339     }
340     return getWidth();
341   }
342 
343   public void setCurrentWidth(org.apache.myfaces.tobago.layout.Measure currentWidth) {
344     getStateHelper().put(PropertyKeys.currentWidth, currentWidth);
345   }
346 
347   public org.apache.myfaces.tobago.layout.Measure getMarginTop() {
348     Object object = getStateHelper().eval(PropertyKeys.marginTop);
349     if (object != null) {
350        return Measure.valueOf(object);
351     }
352     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginTop(getFacesContext(), this) : Measure.ZERO;
353   }
354 
355   public void setMarginTop(org.apache.myfaces.tobago.layout.Measure marginTop) {
356     getStateHelper().put(PropertyKeys.marginTop, marginTop);
357   }
358 
359   /**
360   This value will usually be set by the layout manager.
361 
362   */
363   public org.apache.myfaces.tobago.layout.Measure getWidth() {
364     Object object = getStateHelper().eval(PropertyKeys.width);
365     if (object != null) {
366        return Measure.valueOf(object);
367     }
368     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getWidth(getFacesContext(), this) : Measure.ZERO;
369   }
370 
371   public void setWidth(org.apache.myfaces.tobago.layout.Measure width) {
372     getStateHelper().put(PropertyKeys.width, width);
373   }
374 
375   public org.apache.myfaces.tobago.layout.Measure getMarginRight() {
376     Object object = getStateHelper().eval(PropertyKeys.marginRight);
377     if (object != null) {
378        return Measure.valueOf(object);
379     }
380     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginRight(getFacesContext(), this) : Measure.ZERO;
381   }
382 
383   public void setMarginRight(org.apache.myfaces.tobago.layout.Measure marginRight) {
384     getStateHelper().put(PropertyKeys.marginRight, marginRight);
385   }
386 
387   /**
388   This value will usually be set by the layout manager. It holds the current height computed by the layout manager.
389 
390   */
391   public org.apache.myfaces.tobago.layout.Measure getCurrentHeight() {
392     Object object = getStateHelper().eval(PropertyKeys.currentHeight);
393     if (object != null) {
394        return Measure.valueOf(object);
395     }
396     return getHeight();
397   }
398 
399   public void setCurrentHeight(org.apache.myfaces.tobago.layout.Measure currentHeight) {
400     getStateHelper().put(PropertyKeys.currentHeight, currentHeight);
401   }
402 
403   public org.apache.myfaces.tobago.layout.Measure getPreferredHeight() {
404     Object object = getStateHelper().eval(PropertyKeys.preferredHeight);
405     if (object != null) {
406        return Measure.valueOf(object);
407     }
408     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getPreferredHeight(getFacesContext(), this) : Measure.ZERO;
409   }
410 
411   public void setPreferredHeight(org.apache.myfaces.tobago.layout.Measure preferredHeight) {
412     getStateHelper().put(PropertyKeys.preferredHeight, preferredHeight);
413   }
414 
415   /**
416   Text value to display as label.
417    If text contains an underscore the next character is used as accesskey.
418 
419   */
420   public java.lang.String getLabel() {
421     return (java.lang.String) getStateHelper().eval(PropertyKeys.label);
422   }
423 
424   public void setLabel(java.lang.String label) {
425     getStateHelper().put(PropertyKeys.label, label);
426   }
427 
428   /**
429   This attribute is for internal use only.
430 
431   */
432   public org.apache.myfaces.tobago.layout.Display getDisplay() {
433     return (org.apache.myfaces.tobago.layout.Display) getStateHelper().eval(PropertyKeys.display);
434   }
435 
436   public void setDisplay(org.apache.myfaces.tobago.layout.Display display) {
437     getStateHelper().put(PropertyKeys.display, display);
438   }
439 
440   public org.apache.myfaces.tobago.layout.Measure getMaximumWidth() {
441     Object object = getStateHelper().eval(PropertyKeys.maximumWidth);
442     if (object != null) {
443        return Measure.valueOf(object);
444     }
445     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMaximumWidth(getFacesContext(), this) : Measure.ZERO;
446   }
447 
448   public void setMaximumWidth(org.apache.myfaces.tobago.layout.Measure maximumWidth) {
449     getStateHelper().put(PropertyKeys.maximumWidth, maximumWidth);
450   }
451 
452   /**
453   Client side script function to add to this component's onchange handler.
454 
455   @deprecated*/
456   @Deprecated
457   public java.lang.String getOnchange() {
458     return (java.lang.String) getStateHelper().eval(PropertyKeys.onchange);
459   }
460 
461   @Deprecated
462   public void setOnchange(java.lang.String onchange) {
463       Deprecation.LOG.error("The attribute 'onchange' of 'UISelectOneChoice' is deprecated. "
464           + "Please refer the documentation for further information.");
465     getStateHelper().put(PropertyKeys.onchange, onchange);
466   }
467 
468   public org.apache.myfaces.tobago.layout.Measure getPreferredWidth() {
469     Object object = getStateHelper().eval(PropertyKeys.preferredWidth);
470     if (object != null) {
471        return Measure.valueOf(object);
472     }
473     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getPreferredWidth(getFacesContext(), this) : Measure.ZERO;
474   }
475 
476   public void setPreferredWidth(org.apache.myfaces.tobago.layout.Measure preferredWidth) {
477     getStateHelper().put(PropertyKeys.preferredWidth, preferredWidth);
478   }
479 
480   public org.apache.myfaces.tobago.layout.Measure getMarginBottom() {
481     Object object = getStateHelper().eval(PropertyKeys.marginBottom);
482     if (object != null) {
483        return Measure.valueOf(object);
484     }
485     return getRendererType() != null ? ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginBottom(getFacesContext(), this) : Measure.ZERO;
486   }
487 
488   public void setMarginBottom(org.apache.myfaces.tobago.layout.Measure marginBottom) {
489     getStateHelper().put(PropertyKeys.marginBottom, marginBottom);
490   }
491 
492   /**
493   This attribute is for internal use only.
494 
495   */
496   public java.lang.Integer getVerticalIndex() {
497     Number value  = (Number) getStateHelper().eval(PropertyKeys.verticalIndex);
498     if (value != null) {
499       return value.intValue();
500     }
501     return null;
502   }
503 
504   public void setVerticalIndex(java.lang.Integer verticalIndex) {
505     getStateHelper().put(PropertyKeys.verticalIndex, verticalIndex);
506   }
507 
508   public org.apache.myfaces.tobago.context.Markup getCurrentMarkup() {
509     if (currentMarkup != null) {
510       return currentMarkup;
511     }
512     return null;
513   }
514 
515   public void setCurrentMarkup(org.apache.myfaces.tobago.context.Markup currentMarkup) {
516     this.currentMarkup = currentMarkup;
517   }
518 
519   /**
520   This attribute is for internal use only.
521 
522   */
523   public java.lang.Integer getHorizontalIndex() {
524     Number value  = (Number) getStateHelper().eval(PropertyKeys.horizontalIndex);
525     if (value != null) {
526       return value.intValue();
527     }
528     return null;
529   }
530 
531   public void setHorizontalIndex(java.lang.Integer horizontalIndex) {
532     getStateHelper().put(PropertyKeys.horizontalIndex, horizontalIndex);
533   }
534 
535   /**
536   Flag indicating that this component will prohibit changes by the user.
537   <br />Default: <code>false</code>
538   */
539   public boolean isReadonly() {
540     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.readonly);
541     if (bool != null) {
542       return bool;
543     }
544     return false;
545   }
546 
547   public void setReadonly(boolean readonly) {
548     getStateHelper().put(PropertyKeys.readonly, readonly);
549   }
550 
551   /**
552   Flag indicating that this element is disabled.
553   <br />Default: <code>false</code>
554   */
555   public boolean isDisabled() {
556     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.disabled);
557     if (bool != null) {
558       return bool;
559     }
560     return false;
561   }
562 
563   public void setDisabled(boolean disabled) {
564     getStateHelper().put(PropertyKeys.disabled, disabled);
565   }
566 
567   public Object saveState(FacesContext context) {
568     currentMarkup = null;
569     return super.saveState(context);
570   }
571 
572 
573 }