1 33 34 package com.icesoft.faces.component.ext; 35 36 import com.icesoft.faces.component.CSS_DEFAULT; 37 import com.icesoft.faces.component.ext.taglib.Util; 38 import com.icesoft.faces.context.effects.CurrentStyle; 39 import com.icesoft.faces.context.effects.Effect; 40 import com.icesoft.faces.context.effects.JavascriptContext; 41 42 import javax.faces.context.FacesContext; 43 import javax.faces.el.ValueBinding; 44 45 46 52 public class HtmlOutputLabel 53 extends javax.faces.component.html.HtmlOutputLabel { 54 public static final String COMPONENT_TYPE = 55 "com.icesoft.faces.HtmlOutputLabel"; 56 public static final String RENDERER_TYPE = "com.icesoft.faces.Label"; 57 private static final boolean DEFAULT_VISIBLE = true; 58 private String styleClass = null; 59 private String renderedOnUserRole = null; 60 private Effect effect; 61 private Boolean visible = null; 62 private CurrentStyle currentStyle; 63 64 public HtmlOutputLabel() { 65 super(); 66 setRendererType(RENDERER_TYPE); 67 } 68 69 public void setValueBinding(String s, ValueBinding vb) { 70 if (s != null && s.indexOf("effect") != -1) { 71 JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS, 73 getFacesContext()); 74 } 75 super.setValueBinding(s, vb); 76 } 77 78 81 public void setEffect(Effect effect) { 82 this.effect = effect; 83 JavascriptContext 84 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext()); 85 } 86 87 90 public Effect getEffect() { 91 if (effect != null) { 92 return effect; 93 } 94 ValueBinding vb = getValueBinding("effect"); 95 return vb != null ? (Effect) vb.getValue(getFacesContext()) : null; 96 } 97 98 101 public void setVisible(boolean visible) { 102 this.visible = Boolean.valueOf(visible); 103 } 104 105 108 public boolean getVisible() { 109 if (visible != null) { 110 return visible.booleanValue(); 111 } 112 ValueBinding vb = getValueBinding("visible"); 113 Boolean boolVal = 114 vb != null ? (Boolean ) vb.getValue(getFacesContext()) : null; 115 return boolVal != null ? boolVal.booleanValue() : DEFAULT_VISIBLE; 116 } 117 118 121 public void setStyleClass(String styleClass) { 122 this.styleClass = styleClass; 123 } 124 125 128 public String getStyleClass() { 129 return Util.getQualifiedStyleClass(this, 130 styleClass, 131 CSS_DEFAULT.OUTPUT_LABEL_DEFAULT_STYLE_CLASS, 132 "styleClass"); 133 134 } 135 136 139 public void setRenderedOnUserRole(String renderedOnUserRole) { 140 this.renderedOnUserRole = renderedOnUserRole; 141 } 142 143 146 public String getRenderedOnUserRole() { 147 if (renderedOnUserRole != null) { 148 return renderedOnUserRole; 149 } 150 ValueBinding vb = getValueBinding("renderedOnUserRole"); 151 return vb != null ? (String ) vb.getValue(getFacesContext()) : null; 152 } 153 154 157 public boolean isRendered() { 158 if (!Util.isRenderedOnUserRole(this)) { 159 return false; 160 } 161 return super.isRendered(); 162 } 163 164 167 public CurrentStyle getCurrentStyle() { 168 return currentStyle; 169 } 170 171 174 public void setCurrentStyle(CurrentStyle currentStyle) { 175 this.currentStyle = currentStyle; 176 } 177 178 182 public Object saveState(FacesContext context) { 183 Object values[] = new Object [6]; 184 values[0] = super.saveState(context); 185 values[1] = renderedOnUserRole; 186 values[2] = styleClass; 187 values[3] = effect; 188 values[4] = currentStyle; 189 values[5] = visible; 190 return ((Object ) (values)); 191 } 192 193 197 public void restoreState(FacesContext context, Object state) { 198 Object values[] = (Object []) state; 199 super.restoreState(context, values[0]); 200 renderedOnUserRole = (String ) values[1]; 201 styleClass = (String ) values[2]; 202 effect = (Effect) values[3]; 203 currentStyle = (CurrentStyle) values[4]; 204 visible = (Boolean ) values[5]; 205 } 206 } 207 | Popular Tags |