Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: javax/faces/component/UISelectOne.java


1   /*
2    * Copyright 2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package javax.faces.component;
17  
18  import javax.faces.component._SelectItemsUtil._ValueConverter;
19  import javax.faces.context.FacesContext;
20  
21  /**
22   * see Javadoc of JSF Specification
23   * 
24   * @author Manfred Geiler (latest modification by $Author: mbr $)
25   * @version $Revision: 279434 $ $Date: 2005-09-07 18:06:36 -0400 (Wed, 07 Sep 2005) $
26   */
27  public class UISelectOne extends UIInput
28  {
29      public static final String INVALID_MESSAGE_ID = "javax.faces.component.UISelectOne.INVALID";
30  
31      /**
32       * @see javax.faces.component.UIInput#validateValue(javax.faces.context.FacesContext, java.lang.Object)
33       */
34      protected void validateValue(FacesContext context, Object value)
35      {
36          super.validateValue(context, value);
37  
38          if (!isValid() || value == null)
39          {
40              return;
41          }
42  
43          _ValueConverter converter = new _ValueConverter()
44          {
45              public Object getConvertedValue(FacesContext context, String value)
46              {
47                  return UISelectOne.this.getConvertedValue(context, value);
48              }
49          };
50  
51          // selected value must match to one of the available options
52          if (!_SelectItemsUtil.matchValue(context, value, new _SelectItemsIterator(this), converter))
53          {
54              _MessageUtils.addErrorMessage(context, this, INVALID_MESSAGE_ID,
55                              new Object[] {getId()});
56              setValid(false);
57          }
58      }
59  
60      //------------------ GENERATED CODE BEGIN (do not modify!) --------------------
61  
62      public static final String COMPONENT_TYPE = "javax.faces.SelectOne";
63      public static final String COMPONENT_FAMILY = "javax.faces.SelectOne";
64      private static final String DEFAULT_RENDERER_TYPE = "javax.faces.Menu";
65  
66      public UISelectOne()
67      {
68          setRendererType(DEFAULT_RENDERER_TYPE);
69      }
70  
71      public String getFamily()
72      {
73          return COMPONENT_FAMILY;
74      }
75  
76      //------------------ GENERATED CODE END ---------------------------------------
77  }