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 javax.faces.el.ValueBinding;
23  
24  /**
25   * This tag associates a set of selection list items with the nearest
26   * parent UIComponent. The set of SelectItem objects is retrieved via
27   * a value-binding.
28   * <p>
29   * Unless otherwise specified, all attributes accept static values
30   * or EL expressions.
31   * </p> 
32   * See Javadoc of <a href="http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/api/index.html">JSF Specification</a>
33   *
34   * @JSFComponent
35   *   name = "f:selectItems"
36   *   bodyContent = "empty"
37   *   tagClass = "org.apache.myfaces.taglib.core.SelectItemsTag"
38   *   desc = "UISelectItems"
39   *
40   * @author Manfred Geiler (latest modification by $Author: lu4242 $)
41   * @version $Revision: 684004 $ $Date: 2008-08-08 10:53:07 -0500 (Fri, 08 Aug 2008) $
42   */
43  public class UISelectItems
44          extends UIComponentBase
45  {
46      //------------------ GENERATED CODE BEGIN (do not modify!) --------------------
47  
48      public static final String COMPONENT_TYPE = "javax.faces.SelectItems";
49      public static final String COMPONENT_FAMILY = "javax.faces.SelectItems";
50  
51      private Object _value = null;
52  
53      public UISelectItems()
54      {
55      }
56  
57      public String getFamily()
58      {
59          return COMPONENT_FAMILY;
60      }
61      
62      /**
63       * Disable this property; although this class extends a base-class that
64       * defines a read/write rendered property, this particular subclass
65       * does not support setting it. Yes, this is broken OO design: direct
66       * all complaints to the JSF spec group.
67       *
68       * @JSFProperty tagExcluded="true"
69       */
70      public void setRendered(boolean state) {
71          //throw new UnsupportedOperationException();
72          //Restored due to compatibility with TCK tests.
73          super.setRendered(state);
74      }
75  
76      public boolean isRendered() {
77          //return true;
78          //Restored due to compatibility with TCK tests.
79          return super.isRendered();
80      }
81  
82      public void setValue(Object value)
83      {
84          _value = value;
85      }
86  
87      /**
88       * An EL expression that specifies the contents of the selection list.
89       * The expression can refer to one of the following:
90       * <ol>
91       * <li>A single SelectItem</li>
92       * <li>An array or Collection of SelectItem instances</li>
93       * <li>A Map. The contents of the Map are used to create SelectItem
94       *     instances, where the SelectItem's label is the map's key value, 
95       *     and the SelectItem's value is the map's value. When using a
96       *     map, it is recommended that an ordered implementation such as
97       *     java.util.TreeMap is used.</li>
98       * </ol>
99       * The value properties of each of the SelectItems must be of the same
100      * basic type as the parent component's value.
101      * 
102      * @JSFProperty
103      */
104     public Object getValue()
105     {
106         if (_value != null) return _value;
107         ValueBinding vb = getValueBinding("value");
108         return vb != null ? vb.getValue(getFacesContext()) : null;
109     }
110 
111 
112     public Object saveState(FacesContext context)
113     {
114         Object values[] = new Object[2];
115         values[0] = super.saveState(context);
116         values[1] = _value;
117         return values;
118     }
119 
120     public void restoreState(FacesContext context, Object state)
121     {
122         Object values[] = (Object[])state;
123         super.restoreState(context, values[0]);
124         _value = values[1];
125     }
126     //------------------ GENERATED CODE END ---------------------------------------
127 }