1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package javax.faces.component; |
20 | |
|
21 | |
import javax.el.ValueExpression; |
22 | |
import javax.faces.el.ValueBinding; |
23 | |
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFComponent; |
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
@JSFComponent(defaultRendererType = "javax.faces.Checkbox") |
37 | |
public class UISelectBoolean extends UIInput |
38 | |
{ |
39 | |
public static final String COMPONENT_TYPE = "javax.faces.SelectBoolean"; |
40 | |
public static final String COMPONENT_FAMILY = "javax.faces.SelectBoolean"; |
41 | |
|
42 | |
public UISelectBoolean() |
43 | 0 | { |
44 | 0 | setRendererType("javax.faces.Checkbox"); |
45 | 0 | } |
46 | |
|
47 | |
@Override |
48 | |
public String getFamily() |
49 | |
{ |
50 | 0 | return COMPONENT_FAMILY; |
51 | |
} |
52 | |
|
53 | |
public void setSelected(boolean selected) |
54 | |
{ |
55 | 0 | setValue(Boolean.valueOf(selected)); |
56 | 0 | } |
57 | |
|
58 | |
public boolean isSelected() |
59 | |
{ |
60 | 0 | Boolean value = (Boolean) getSubmittedValue(); |
61 | 0 | if (value == null) |
62 | |
{ |
63 | 0 | value = (Boolean) getValue(); |
64 | |
} |
65 | |
|
66 | 0 | return value != null ? value.booleanValue() : false; |
67 | |
} |
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
public ValueBinding getValueBinding(String name) |
73 | |
{ |
74 | 0 | if (name == null) |
75 | |
{ |
76 | 0 | throw new NullPointerException("name"); |
77 | |
} |
78 | 0 | if (name.equals("selected")) |
79 | |
{ |
80 | 0 | return super.getValueBinding("value"); |
81 | |
} |
82 | |
else |
83 | |
{ |
84 | 0 | return super.getValueBinding(name); |
85 | |
} |
86 | |
} |
87 | |
|
88 | |
|
89 | |
|
90 | |
|
91 | |
public void setValueBinding(String name, ValueBinding binding) |
92 | |
{ |
93 | 0 | if (name == null) |
94 | |
{ |
95 | 0 | throw new NullPointerException("name"); |
96 | |
} |
97 | 0 | if (name.equals("selected")) |
98 | |
{ |
99 | 0 | super.setValueBinding("value", binding); |
100 | |
} |
101 | |
else |
102 | |
{ |
103 | 0 | super.setValueBinding(name, binding); |
104 | |
} |
105 | 0 | } |
106 | |
|
107 | |
public ValueExpression getValueExpression(String name) |
108 | |
{ |
109 | 0 | if (name == null) |
110 | |
{ |
111 | 0 | throw new NullPointerException("name"); |
112 | |
} |
113 | 0 | if (name.equals("selected")) |
114 | |
{ |
115 | 0 | return super.getValueExpression("value"); |
116 | |
} |
117 | |
else |
118 | |
{ |
119 | 0 | return super.getValueExpression(name); |
120 | |
} |
121 | |
} |
122 | |
|
123 | |
public void setValueExpression(String name, ValueExpression binding) |
124 | |
{ |
125 | 0 | if (name == null) |
126 | |
{ |
127 | 0 | throw new NullPointerException("name"); |
128 | |
} |
129 | 0 | if (name.equals("selected")) |
130 | |
{ |
131 | 0 | super.setValueExpression("value", binding); |
132 | |
} |
133 | |
else |
134 | |
{ |
135 | 0 | super.setValueExpression(name, binding); |
136 | |
} |
137 | 0 | } |
138 | |
} |