1 16 package org.apache.myfaces.component.html.ext; 17 18 import org.apache.myfaces.component.UserRoleAware; 19 import org.apache.myfaces.component.UserRoleUtils; 20 import org.apache.myfaces.component.html.util.HtmlComponentUtils; 21 22 import javax.faces.context.FacesContext; 23 import javax.faces.el.ValueBinding; 24 25 48 public class HtmlPanelGroup 49 extends javax.faces.component.html.HtmlPanelGroup 50 implements UserRoleAware 51 { 52 public String getClientId(FacesContext context) 53 { 54 String clientId = HtmlComponentUtils.getClientId(this, getRenderer(context), context); 55 if (clientId == null) 56 { 57 clientId = super.getClientId(context); 58 } 59 60 return clientId; 61 } 62 63 65 67 public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlPanelGroup"; 68 69 private String _enabledOnUserRole = null; 70 private String _visibleOnUserRole = null; 71 72 public HtmlPanelGroup() 73 { 74 } 75 76 77 public void setEnabledOnUserRole(String enabledOnUserRole) 78 { 79 _enabledOnUserRole = enabledOnUserRole; 80 } 81 82 public String getEnabledOnUserRole() 83 { 84 if (_enabledOnUserRole != null) return _enabledOnUserRole; 85 ValueBinding vb = getValueBinding("enabledOnUserRole"); 86 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 87 } 88 89 public void setVisibleOnUserRole(String visibleOnUserRole) 90 { 91 _visibleOnUserRole = visibleOnUserRole; 92 } 93 94 public String getVisibleOnUserRole() 95 { 96 if (_visibleOnUserRole != null) return _visibleOnUserRole; 97 ValueBinding vb = getValueBinding("visibleOnUserRole"); 98 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 99 } 100 101 102 public boolean isRendered() 103 { 104 if (!UserRoleUtils.isVisibleOnUserRole(this)) return false; 105 return super.isRendered(); 106 } 107 108 public Object saveState(FacesContext context) 109 { 110 Object values[] = new Object [3]; 111 values[0] = super.saveState(context); 112 values[1] = _enabledOnUserRole; 113 values[2] = _visibleOnUserRole; 114 return ((Object ) (values)); 115 } 116 117 public void restoreState(FacesContext context, Object state) 118 { 119 Object values[] = (Object [])state; 120 super.restoreState(context, values[0]); 121 _enabledOnUserRole = (String )values[1]; 122 _visibleOnUserRole = (String )values[2]; 123 } 124 } 126 | Popular Tags |