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            /**
024            * @see javax.servlet.jsp.tagext.Tag#release()
025            */
026            public void release()   {
027                    super.release();
028                    interval=-1;
029            }
030    
031            /** set the value interval
032            *  Flush the output each time at least the specified number of bytes become available. HTML 
033            *               headers, and any data that is already available when you make this call, are not included in 
034            *               the count.
035            * @param interval value to set
036            **/
037            public void setInterval(double interval)        {
038                    this.interval=interval;
039            }
040    
041    
042            /**
043            * @see javax.servlet.jsp.tagext.Tag#doStartTag()
044            */
045            public int doStartTag() throws PageException    {
046            try {
047                            if(interval==-1)((PageContextImpl)pageContext).getRootOut().flush();
048                            else ((PageContextImpl)pageContext).getRootOut().setBufferConfig((int)interval,true);
049                    } catch (IOException e) {
050                            throw Caster.toPageException(e);
051                    }
052                    return SKIP_BODY;
053            }
054    
055            /**
056            * @see javax.servlet.jsp.tagext.Tag#doEndTag()
057            */
058            public int doEndTag()   {
059                    return EVAL_PAGE;
060            }
061    }