1 17 package org.alfresco.web.ui.common.component.evaluator; 18 19 import java.io.IOException ; 20 21 import javax.faces.context.FacesContext; 22 import javax.faces.el.ValueBinding; 23 24 import org.apache.log4j.Logger; 25 26 import org.alfresco.web.ui.common.component.SelfRenderingComponent; 27 28 31 public abstract class BaseEvaluator extends SelfRenderingComponent 32 { 33 36 public final String getFamily() 37 { 38 return "org.alfresco.faces.evaluators"; 39 } 40 41 44 public final boolean getRendersChildren() 45 { 46 return !evaluate(); 47 } 48 49 52 public final void encodeBegin(FacesContext context) throws IOException 53 { 54 } 56 57 60 public final void encodeChildren(FacesContext context) throws IOException 61 { 62 } 65 66 69 public final void encodeEnd(FacesContext context) throws IOException 70 { 71 } 73 74 79 public Object getValue() 80 { 81 ValueBinding vb = getValueBinding("value"); 82 if (vb != null) 83 { 84 this.value = vb.getValue(getFacesContext()); 85 } 86 87 return this.value; 88 } 89 90 95 public void setValue(Object value) 96 { 97 this.value = value; 98 } 99 100 103 public void restoreState(FacesContext context, Object state) 104 { 105 Object values[] = (Object [])state; 106 super.restoreState(context, values[0]); 108 this.value = values[1]; 109 } 110 111 114 public Object saveState(FacesContext context) 115 { 116 Object values[] = new Object [2]; 117 values[0] = super.saveState(context); 119 values[1] = this.value; 120 return (values); 121 } 122 123 129 public abstract boolean evaluate(); 130 131 132 protected static Logger s_logger = Logger.getLogger(BaseEvaluator.class); 133 134 135 private Object value; 136 } 137 | Popular Tags |