1 16 package org.apache.myfaces.custom.tabbedpane; 17 18 import javax.faces.component.html.HtmlPanelGroup; 19 import javax.faces.context.FacesContext; 20 import javax.faces.el.ValueBinding; 21 22 import org.apache.myfaces.component.UserRoleUtils; 23 24 28 public class HtmlPanelTab 29 extends HtmlPanelGroup 30 { 31 33 34 36 public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlPanelTab"; 37 public static final String COMPONENT_FAMILY = "javax.faces.Panel"; 38 private static final String DEFAULT_RENDERER_TYPE = "javax.faces.Group"; 39 40 private String _label = null; 41 42 public HtmlPanelTab() 43 { 44 setRendererType(DEFAULT_RENDERER_TYPE); 45 } 46 47 public String getFamily() 48 { 49 return COMPONENT_FAMILY; 50 } 51 52 public void setLabel(String label) 53 { 54 _label = label; 55 } 56 57 public String getLabel() 58 { 59 if (_label != null) return _label; 60 ValueBinding vb = getValueBinding("label"); 61 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 62 } 63 64 65 public Object saveState(FacesContext context) 66 { 67 Object values[] = new Object [2]; 68 values[0] = super.saveState(context); 69 values[1] = _label; 70 return ((Object ) (values)); 71 } 72 73 public void restoreState(FacesContext context, Object state) 74 { 75 Object values[] = (Object [])state; 76 super.restoreState(context, values[0]); 77 _label = (String )values[1]; 78 } 79 81 82 public boolean isRendered() 83 { 84 if (!UserRoleUtils.isVisibleOnUserRole(this)) { 85 return false; 86 } 87 return super.isRendered(); 88 } 89 } 90 | Popular Tags |