1 16 package javax.faces.component; 17 18 import javax.faces.el.ValueBinding; 19 20 21 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 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 } 92 | Popular Tags |