Subversion Repositories general

Rev

Blame | Last modification | View Log | RSS feed

package ak.backpath.taglib;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
import ak.backpath.BackPath;

/**
 * This tag just does nothing but saves a backpath object into request with given params,
 * should be used at the top pf JSp to ensure that all tags use correct backpath params.
 */
public class InitTag extends TagSupport
{
    protected String backPathKey = BackPath.DEFAULT_KEY;

    public String getBackPathKey()
    {
        return this.backPathKey;
    }

    public void setBackPathKey(String backPathKey)
    {
        this.backPathKey = backPathKey;
    }

    protected String backPathParam = BackPath.DEFAULT_PARAM;

    public String getBackPathParam()
    {
        return this.backPathParam;
    }

    public void setBackPathParam(String backPathParam)
    {
        this.backPathParam = backPathParam;
    }

    protected String backPathIgnore = null;

    public String getBackPathIgnore()
    {
        return this.backPathIgnore;
    }

    public void setBackPathIgnore(String backPathIgnore)
    {
        this.backPathIgnore = backPathIgnore;
    }

    protected boolean zip = BackPath.DEFAULT_ZIP;

    public boolean getZip()
    {
        return this.zip;
    }

    public void setZip(boolean zip)
    {
        this.zip = zip;
    }

    public void release()
    {
        super.release();
        backPathKey    = BackPath.DEFAULT_KEY;
        backPathParam  = BackPath.DEFAULT_PARAM;
        backPathIgnore = null;
        zip            = BackPath.DEFAULT_ZIP;
    }

    public int doStartTag() throws JspException
    {
        // remove old, if any
                ((HttpServletRequest)pageContext.getRequest()).removeAttribute(backPathKey);

                // create a new one
        TaglibUtils.findBackPath(pageContext, backPathKey, backPathParam, backPathIgnore, zip);

                return (SKIP_BODY);
    }

    public int doEndTag() throws JspException
    {
        return (EVAL_PAGE);
    }
}