Subversion Repositories bacoAlunos

Rev

Rev 215 | Blame | Compare with Previous | Last modification | View Log | RSS feed

package pt.estgp.estgweb.web.tags;

import org.apache.log4j.Logger;

import javax.servlet.jsp.tagext.BodyTagSupport;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;

import pt.estgp.estgweb.domain.UserSessionImpl;
import pt.estgp.estgweb.Globals;
import pt.estgp.estgweb.utils.ConfigProperties;

public class IsModuleOnTag extends BodyTagSupport
{

    private static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(IsModuleOnTag.class);


    private 1.5.0/docs/api/java/lang/String.html">String module;


    public 1.5.0/docs/api/java/lang/String.html">String getModule()
    {
        return module;
    }

    public void setModule(1.5.0/docs/api/java/lang/String.html">String module)
    {
        this.module = module;
    }

    public int doStartTag() throws JspException
    {
        if(go())
            return EVAL_BODY_TAG;
        else
            return SKIP_BODY;
    }

    public boolean go()
    {
        return ConfigProperties.getBooleanProperty(Globals.MODULE_STATUS_PREFIX + module);
    }

    public int doEndTag() throws JspException
    {
        if (go())
        {
            1.5.0/docs/api/java/lang/String.html">String toPage = bodyContent.getString().trim();
            JspWriter writer = pageContext.getOut();
            try
            {
                writer.write(toPage);
            }
            catch (1.5.0/docs/api/java/lang/Exception.html">Exception e)
            {
                logger.error(e, e);
                throw new JspException(e);
            }
        }

        // Continue processing this page
        return EVAL_PAGE;
    }


}