001 package railo.runtime.tag; 002 003 import java.io.IOException; 004 005 import railo.runtime.PageContextImpl; 006 import railo.runtime.exp.PageException; 007 import railo.runtime.ext.tag.TagImpl; 008 import railo.runtime.op.Caster; 009 010 /** 011 * Flushes currently available data to the client. 012 * 013 * 014 * 015 **/ 016 public final class Flush extends TagImpl { 017 018 /** Flush the output each time at least the specified number of bytes become available. HTML 019 ** headers, and any data that is already available when you make this call, are not included in 020 ** the count. */ 021 private double interval=-1; 022 023 @Override 024 public void release() { 025 super.release(); 026 interval=-1; 027 } 028 029 /** set the value interval 030 * Flush the output each time at least the specified number of bytes become available. HTML 031 * headers, and any data that is already available when you make this call, are not included in 032 * the count. 033 * @param interval value to set 034 **/ 035 public void setInterval(double interval) { 036 this.interval=interval; 037 } 038 039 040 @Override 041 public int doStartTag() throws PageException { 042 try { 043 if(interval==-1)((PageContextImpl)pageContext).getRootOut().flush(); 044 else ((PageContextImpl)pageContext).getRootOut().setBufferConfig((int)interval,true); 045 } catch (IOException e) { 046 throw Caster.toPageException(e); 047 } 048 return SKIP_BODY; 049 } 050 051 @Override 052 public int doEndTag() { 053 return EVAL_PAGE; 054 } 055 }