package javax.servlet.jsp.tagext;

import javax.servlet.jsp.JspException;

/** A useful base class for tags wishing to implement the
   * RunnableTag interface
   */
public abstract class RunnableTagSupport extends TagSupport implements RunnableTag {

    /** The helper object which generates my body content on demand */
    protected TagRunner tagRunner;

    public RunnableTagSupport() {
    }

    /** Generates my body content to my PageContext
       */
    public void run() throws JspException {
        if ( tagRunner == null ) {
            throw new JspException( 
                "Invalid JSP code generated. " 
                + "setTagRunner() not called correctly on this instance"
            );
        }
        else {
            tagRunner.run( this );
        }
    }

    public void setTagRunner( TagRunner tagRunner ) {
        this.tagRunner = tagRunner;
    }
}


