1 4 package org.apache.myfaces.custom.jslistener; 5 6 import javax.faces.component.UIOutput; 7 import javax.faces.context.FacesContext; 8 import javax.faces.el.ValueBinding; 9 10 21 public class JsValueChangeListener extends UIOutput 22 { 23 25 public static final String COMPONENT_TYPE = "org.apache.myfaces.JsValueChangeListener"; 26 public static final String COMPONENT_FAMILY = "javax.faces.Output"; 27 private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.JsValueChangeListener"; 28 29 private String _for = null; 30 private String _expressionValue = null; 31 private String _property = null; 32 33 public JsValueChangeListener() 34 { 35 setRendererType(DEFAULT_RENDERER_TYPE); 36 } 37 38 public String getFamily() 39 { 40 return COMPONENT_FAMILY; 41 } 42 43 public void setFor(String forValue) 44 { 45 _for = forValue; 46 } 47 48 public String getFor() 49 { 50 if (_for != null) return _for; 51 ValueBinding vb = getValueBinding("for"); 52 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 53 } 54 55 public void setExpressionValue(String expressionValue) 56 { 57 _expressionValue = expressionValue; 58 } 59 60 public String getExpressionValue() 61 { 62 if (_expressionValue != null) return _expressionValue; 63 ValueBinding vb = getValueBinding("expressionValue"); 64 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 65 } 66 67 public void setProperty(String property) 68 { 69 _property = property; 70 } 71 72 public String getProperty() 73 { 74 if (_property != null) return _property; 75 ValueBinding vb = getValueBinding("property"); 76 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 77 } 78 79 80 81 public Object saveState(FacesContext context) 82 { 83 Object values[] = new Object [4]; 84 values[0] = super.saveState(context); 85 values[1] = _for; 86 values[2] = _expressionValue; 87 values[3] = _property; 88 return ((Object ) (values)); 89 } 90 91 public void restoreState(FacesContext context, Object state) 92 { 93 Object values[] = (Object [])state; 94 super.restoreState(context, values[0]); 95 _for = (String )values[1]; 96 _expressionValue = (String )values[2]; 97 _property = (String )values[3]; 98 } 99 } 101 | Popular Tags |