1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package javax.faces.component; |
17 | |
|
18 | |
import javax.faces.el.ValueBinding; |
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
public class UISelectBoolean extends UIInput { |
24 | |
|
25 | |
public static final String COMPONENT_TYPE = "javax.faces.SelectBoolean"; |
26 | |
|
27 | |
public static final String COMPONENT_FAMILY = "javax.faces.SelectBoolean"; |
28 | |
|
29 | |
private static final String DEFAULT_RENDERER_TYPE = "javax.faces.Checkbox"; |
30 | |
|
31 | 300 | public UISelectBoolean() { |
32 | 300 | setRendererType(DEFAULT_RENDERER_TYPE); |
33 | 300 | } |
34 | |
|
35 | |
public String getFamily() { |
36 | 26 | return COMPONENT_FAMILY; |
37 | |
} |
38 | |
|
39 | |
public boolean isSelected() { |
40 | 8 | Boolean value = (Boolean) getValue(); |
41 | 8 | if (value != null) { |
42 | 6 | return value.booleanValue(); |
43 | |
} else { |
44 | 2 | return false; |
45 | |
} |
46 | |
} |
47 | |
|
48 | |
public void setSelected(boolean selected) { |
49 | 6 | if (selected) { |
50 | 4 | setValue(Boolean.TRUE); |
51 | |
} else { |
52 | 2 | setValue(Boolean.FALSE); |
53 | |
} |
54 | 6 | } |
55 | |
|
56 | |
public ValueBinding getValueBinding(String name) { |
57 | 277 | return super.getValueBinding(convertAlias(name)); |
58 | |
} |
59 | |
|
60 | |
public void setValueBinding(String name, ValueBinding vb) { |
61 | 62 | super.setValueBinding(convertAlias(name), vb); |
62 | 56 | } |
63 | |
|
64 | |
private String convertAlias(String name) { |
65 | 339 | if ("selected".equals(name)) { |
66 | 10 | return "value"; |
67 | |
} |
68 | 329 | return name; |
69 | |
} |
70 | |
|
71 | |
} |