1 16 package org.apache.myfaces.custom.navmenu.jscookmenu; 17 18 import org.apache.myfaces.component.UserRoleUtils; 19 import org.apache.myfaces.component.UserRoleAware; 20 21 import javax.faces.component.UICommand; 22 import javax.faces.el.ValueBinding; 23 import javax.faces.context.FacesContext; 24 25 45 public class HtmlCommandJSCookMenu 46 extends UICommand 47 implements UserRoleAware 48 { 49 51 53 public static final String COMPONENT_TYPE = "org.apache.myfaces.JSCookMenu"; 54 public static final String COMPONENT_FAMILY = "javax.faces.Command"; 55 56 private String _layout = null; 57 private String _theme = null; 58 private String _enabledOnUserRole = null; 59 private String _visibleOnUserRole = null; 60 61 public HtmlCommandJSCookMenu() 62 { 63 } 64 65 public String getFamily() 66 { 67 return COMPONENT_FAMILY; 68 } 69 70 public boolean isImmediate() 71 { 72 return true; 73 } 74 75 public void setLayout(String layout) 76 { 77 _layout = layout; 78 } 79 80 public String getLayout() 81 { 82 if (_layout != null) return _layout; 83 ValueBinding vb = getValueBinding("layout"); 84 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 85 } 86 87 public void setTheme(String theme) 88 { 89 _theme = theme; 90 } 91 92 public String getTheme() 93 { 94 if (_theme != null) return _theme; 95 ValueBinding vb = getValueBinding("theme"); 96 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 97 } 98 99 public void setEnabledOnUserRole(String enabledOnUserRole) 100 { 101 _enabledOnUserRole = enabledOnUserRole; 102 } 103 104 public String getEnabledOnUserRole() 105 { 106 if (_enabledOnUserRole != null) return _enabledOnUserRole; 107 ValueBinding vb = getValueBinding("enabledOnUserRole"); 108 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 109 } 110 111 public void setVisibleOnUserRole(String visibleOnUserRole) 112 { 113 _visibleOnUserRole = visibleOnUserRole; 114 } 115 116 public String getVisibleOnUserRole() 117 { 118 if (_visibleOnUserRole != null) return _visibleOnUserRole; 119 ValueBinding vb = getValueBinding("visibleOnUserRole"); 120 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 121 } 122 123 public boolean isRendered() 124 { 125 if (!UserRoleUtils.isVisibleOnUserRole(this)) return false; 126 return super.isRendered(); 127 } 128 129 public Object saveState(FacesContext context) 130 { 131 Object values[] = new Object [5]; 132 values[0] = super.saveState(context); 133 values[1] = _layout; 134 values[2] = _theme; 135 values[3] = _enabledOnUserRole; 136 values[4] = _visibleOnUserRole; 137 return ((Object ) (values)); 138 } 139 140 public void restoreState(FacesContext context, Object state) 141 { 142 Object values[] = (Object [])state; 143 super.restoreState(context, values[0]); 144 _layout = (String )values[1]; 145 _theme = (String )values[2]; 146 _enabledOnUserRole = (String )values[3]; 147 _visibleOnUserRole = (String )values[4]; 148 } 149 } 151 | Popular Tags |