1 4 package org.apache.myfaces.custom.jsvalueset; 5 6 import org.apache.myfaces.component.UserRoleUtils; 7 8 import javax.faces.component.UIOutput; 9 import javax.faces.el.ValueBinding; 10 import javax.faces.context.FacesContext; 11 12 21 public class HtmlJsValueSet extends UIOutput 22 { 23 24 25 27 public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlJsValueSet"; 28 public static final String COMPONENT_FAMILY = "javax.faces.Output"; 29 private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.JsValueSet"; 30 31 private String _name = null; 32 33 public HtmlJsValueSet() 34 { 35 setRendererType(DEFAULT_RENDERER_TYPE); 36 } 37 38 public String getFamily() 39 { 40 return COMPONENT_FAMILY; 41 } 42 43 public void setName(String name) 44 { 45 _name = name; 46 } 47 48 public String getName() 49 { 50 if (_name != null) return _name; 51 ValueBinding vb = getValueBinding("name"); 52 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 53 } 54 55 56 public boolean isRendered() 57 { 58 if (!UserRoleUtils.isVisibleOnUserRole(this)) return false; 59 return super.isRendered(); 60 } 61 62 public Object saveState(FacesContext context) 63 { 64 Object values[] = new Object [2]; 65 values[0] = super.saveState(context); 66 values[1] = _name; 67 return ((Object ) (values)); 68 } 69 70 public void restoreState(FacesContext context, Object state) 71 { 72 Object values[] = (Object [])state; 73 super.restoreState(context, values[0]); 74 _name = (String )values[1]; 75 } 76 } 78 79 80 | Popular Tags |