1 16 package org.apache.myfaces.custom.buffer; 17 18 import javax.faces.component.UIComponentBase; 19 import javax.faces.context.FacesContext; 20 import javax.faces.el.ValueBinding; 21 22 30 public class Buffer extends UIComponentBase{ 31 32 public static final String COMPONENT_TYPE = "org.apache.myfaces.Buffer"; 33 public static final String COMPONENT_FAMILY = "javax.faces.Data"; 34 private static final String DEFAULT_RENDERER_TYPE = BufferRenderer.RENDERER_TYPE; 35 36 private String _intoExpression = null; 37 38 public Buffer(){ 39 setRendererType(DEFAULT_RENDERER_TYPE); 40 } 41 42 public String getFamily(){ 43 return COMPONENT_FAMILY; 44 } 45 46 public void setInto(String intoExpression){ 47 _intoExpression = intoExpression; 48 } 49 50 public Object saveState(FacesContext context){ 51 Object values[] = new Object [2]; 52 values[0] = super.saveState(context); 53 values[1] = _intoExpression; 54 return values; 55 } 56 57 public void restoreState(FacesContext context, Object state){ 58 Object values[] = (Object []) state; 59 super.restoreState(context, values[0]); 60 _intoExpression = (String ) values[1]; 61 } 62 63 void fill(Object content, FacesContext facesContext){ 64 ValueBinding intoVB; 65 66 if (_intoExpression == null) { 67 intoVB = getValueBinding("into"); 68 _intoExpression = intoVB.getExpressionString(); 69 } else { 70 intoVB = facesContext.getApplication().createValueBinding( _intoExpression ); 71 } 72 73 intoVB.setValue(facesContext, content.toString()); 74 } 75 } | Popular Tags |