View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package javax.faces.component;
20  
21  import javax.faces.context.FacesContext;
22  import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFComponent;
23  import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFProperty;
24  
25  /**
26   * This tag associates a single SelectItem with the nearest parent UIComponent. The item represents a single option for
27   * a component such as an h:selectBooleanCheckbox or h:selectOneMenu. See also component selectItems.
28   * <p>
29   * Unless otherwise specified, all attributes accept static values or EL expressions.
30   * </p>
31   * <p>
32   * UISelectItem should be nestetd inside a UISelectMany or UISelectOne component, and results in the addition of a
33   * SelectItem instance to the list of available options for the parent component
34   * </p>
35   */
36  @JSFComponent(clazz = "javax.faces.component.UISelectItem", template = true, name = "f:selectItem", 
37                tagClass = "org.apache.myfaces.taglib.core.SelectItemTag", bodyContent = "empty")
38  abstract class _UISelectItem extends UIComponentBase
39  {
40  
41      static public final String COMPONENT_FAMILY = "javax.faces.SelectItem";
42      static public final String COMPONENT_TYPE = "javax.faces.SelectItem";
43  
44      /**
45       * Disable this property; although this class extends a base-class that defines a read/write rendered property, this
46       * particular subclass does not support setting it. Yes, this is broken OO design: direct all complaints to the JSF
47       * spec group.
48       */
49      @Override
50      @JSFProperty(tagExcluded = true)
51      public void setRendered(boolean state)
52      {
53          super.setRendered(state);
54          // call parent method due TCK problems
55          // throw new UnsupportedOperationException();
56      }
57  
58      @Override
59      protected FacesContext getFacesContext()
60      {
61          //In theory the parent most of the times has 
62          //the cached FacesContext instance, because this
63          //element is purely logical, and the parent is the one
64          //where encodeXXX was invoked. But only limit the
65          //search to the closest parent.
66          UIComponent parent = getParent();
67          if (parent != null && parent.isCachedFacesContext())
68          {
69              return parent.getFacesContext();
70          }
71          else
72          {
73              return super.getFacesContext();
74          }
75      }
76     
77      /**
78       * The initial value of this component.
79       * 
80       * @return the new value value
81       */
82      @JSFProperty(deferredValueType="javax.faces.model.SelectItem")
83      public abstract Object getValue();
84  
85      /**
86       * Determine whether this item can be chosen by the user. When true, this item cannot be chosen by the user. If this
87       * method is ever called, then any EL-binding for the disabled property will be ignored.
88       * 
89       * @return the new itemDisabled value
90       */
91      @JSFProperty(defaultValue = "false", deferredValueType="java.lang.Boolean")
92      public abstract boolean isItemDisabled();
93  
94      /**
95       * The escape setting for the label of this selection item.
96       * 
97       * @return the new itemEscaped value
98       */
99      @JSFProperty(defaultValue = "true", jspName = "escape", deferredValueType="java.lang.String")
100     public abstract boolean isItemEscaped();
101 
102     /**
103      * For use in development tools.
104      * 
105      * @return the new itemDescription value
106      */
107     @JSFProperty
108     public abstract String getItemDescription();
109 
110     /**
111      * The string which will be presented to the user for this option.
112      * 
113      * @return the new itemLabel value
114      */
115     @JSFProperty
116     public abstract String getItemLabel();
117 
118     /**
119      * The value for this Item.
120      * 
121      * @return the new itemValue value
122      */
123     @JSFProperty
124     public abstract Object getItemValue();
125 
126     /**
127      * Indicate this component represent no selection option. 
128      * Default value is false.
129      * 
130      * @since 2.0
131      * @return is the component represent no select option
132      */
133     @JSFProperty
134     (defaultValue="false", deferredValueType="java.lang.Boolean")
135     public abstract boolean isNoSelectionOption();
136 }