1 16 package org.apache.myfaces.custom.tree; 17 18 import javax.faces.component.UISelectItem; 19 import javax.faces.context.FacesContext; 20 import javax.faces.el.ValueBinding; 21 22 25 public class HtmlTreeCheckbox extends UISelectItem 26 { 27 28 private String forAttr = null; 29 30 31 public static final String FOR_ATTR = "for".intern(); 32 33 34 public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlTreeCheckbox"; 35 36 37 public static final String COMPONENT_FAMILY = "org.apache.myfaces.HtmlTreeCheckbox"; 38 39 40 private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.HtmlTreeCheckbox"; 41 42 47 public HtmlTreeCheckbox() 48 { 49 setRendererType(DEFAULT_RENDERER_TYPE); 50 } 51 52 55 public String getFamily() 56 { 57 return COMPONENT_FAMILY; 58 } 59 60 63 public String getFor() 64 { 65 if (forAttr != null) return forAttr; 66 ValueBinding vb = getValueBinding(FOR_ATTR); 67 return vb != null ? (String ) vb.getValue(getFacesContext()) : null; 68 } 69 70 73 public void setFor(String forAttr) 74 { 75 this.forAttr = forAttr; 76 } 77 78 81 public Object saveState(FacesContext context) 82 { 83 Object values[] = new Object [2]; 84 values[0] = super.saveState(context); 85 values[1] = forAttr; 86 return ((Object ) (values)); 87 } 88 89 92 public void restoreState(FacesContext context, Object state) 93 { 94 Object values[] = (Object [])state; 95 super.restoreState(context, values[0]); 96 forAttr = (String )values[1]; 97 } 98 99 } 100 | Popular Tags |