Source code: javax/faces/component/UISelectBoolean.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.el.ValueBinding;
19
20
21 /**
22 * see Javadoc of JSF Specification
23 *
24 * @author Manfred Geiler (latest modification by $Author: svieujot $)
25 * @version $Revision: 167580 $ $Date: 2005-02-08 13:15:04 -0500 (Tue, 08 Feb 2005) $
26 */
27 public class UISelectBoolean
28 extends UIInput
29 {
30
31 public void setSelected(boolean selected)
32 {
33 setValue(Boolean.valueOf(selected));
34 }
35
36 public boolean isSelected()
37 {
38 Boolean value = (Boolean)getSubmittedValue();
39 if( value == null )
40 value = (Boolean)getValue();
41
42 return value != null ? value.booleanValue() : false;
43 }
44
45 public ValueBinding getValueBinding(String name)
46 {
47 if (name == null) throw new NullPointerException("name");
48 if (name.equals("selected"))
49 {
50 return super.getValueBinding("value");
51 }
52 else
53 {
54 return super.getValueBinding(name);
55 }
56 }
57
58 public void setValueBinding(String name,
59 ValueBinding binding)
60 {
61 if (name == null) throw new NullPointerException("name");
62 if (name.equals("selected"))
63 {
64 super.setValueBinding("value", binding);
65 }
66 else
67 {
68 super.setValueBinding(name, binding);
69 }
70 }
71
72 //------------------ GENERATED CODE BEGIN (do not modify!) --------------------
73
74 public static final String COMPONENT_TYPE = "javax.faces.SelectBoolean";
75 public static final String COMPONENT_FAMILY = "javax.faces.SelectBoolean";
76 private static final String DEFAULT_RENDERER_TYPE = "javax.faces.Checkbox";
77
78
79 public UISelectBoolean()
80 {
81 setRendererType(DEFAULT_RENDERER_TYPE);
82 }
83
84 public String getFamily()
85 {
86 return COMPONENT_FAMILY;
87 }
88
89
90 //------------------ GENERATED CODE END ---------------------------------------
91 }