1 package com.opensymphony.webwork.views.freemarker.tags; 2 3 import com.opensymphony.webwork.components.Component; 4 import freemarker.template.TemplateModelException; 5 import freemarker.template.TransformControl; 6 7 import java.io.IOException ; 8 import java.io.Writer ; 9 10 15 public class CallbackWriter extends Writer implements TransformControl { 16 private Component bean; 17 private Writer writer; 18 19 public CallbackWriter(Component bean, Writer writer) { 20 this.bean = bean; 21 this.writer = writer; 22 } 23 24 public void close() throws IOException { 25 } 26 27 public void flush() throws IOException { 28 writer.flush(); 29 } 30 31 public void write(char cbuf[], int off, int len) throws IOException { 32 writer.write(cbuf, off, len); 33 } 34 35 public int onStart() throws TemplateModelException, IOException { 36 return EVALUATE_BODY; 37 } 38 39 public int afterBody() throws TemplateModelException, IOException { 40 bean.end(this); 41 42 return END_EVALUATION; 43 } 44 45 public void onError(Throwable throwable) throws Throwable { 46 throw throwable; 47 } 48 49 public Component getBean() { 50 return bean; 51 } 52 } 53 | Popular Tags |