package template; import javax.servlet.jsp.tagext.Tag; import javax.servlet.jsp.tagext.IterationTag; import javax.servlet.jsp.tagext.BodyTag; import javax.servlet.jsp.tagext.TagSupport; import javax.servlet.jsp.tagext.BodyTagSupport; import javax.servlet.jsp.tagext.BodyContent; import javax.servlet.jsp.JspException; import javax.servlet.jsp.JspWriter; import javax.servlet.jsp.PageContext; import javax.servlet.ServletRequest; import java.io.PrintWriter; import java.io.IOException; import java.util.*; /** * Generated tag class. */ public class DefinitionTag extends TagSupport { /** property declaration for tag attribute: definitionName. */ private String definitionName; /** property declaration for tag attribute: screenName. */ private String screenName; public DefinitionTag() { super(); } //////////////////////////////////////////////////////////////// /// /// /// User methods. /// /// /// /// Modify these methods to customize your tag handler. /// /// /// //////////////////////////////////////////////////////////////// // // methods called from doStartTag() // /** * * Fill in this method to perform other operations from doStartTag(). * */ public void otherDoStartTagOperations() { HashMap screens = null; screens = (HashMap) pageContext.getAttribute("screens", pageContext.APPLICATION_SCOPE); if (screens == null) pageContext.setAttribute("screens", new HashMap(), pageContext.APPLICATION_SCOPE); } /** * * Fill in this method to determine if the tag body should be evaluated * Called from doStartTag(). * */ public boolean theBodyShouldBeEvaluated() { return true; } // // methods called from doEndTag() // /** * * Fill in this method to perform other operations from doEndTag(). * */ public void otherDoEndTagOperations() { try { Definition definition = new Definition(); HashMap screens = null; ArrayList params = null; screens = (HashMap) pageContext.getAttribute("screens", pageContext.APPLICATION_SCOPE); if (screens != null) { params = (ArrayList) screens.get(screenName); } else Debug.println("DefinitionTag: screens null."); if (params == null) Debug.println("DefinitionTag: params are not defined."); Iterator ir = null; if (params != null) ir = params.iterator(); while ((ir != null) && ir.hasNext()) definition.setParam((Parameter) ir.next()); // put the definition in the page context pageContext.setAttribute(definitionName, definition); } catch (Exception ex) { ex.printStackTrace(); } } /** * * Fill in this method to determine if the rest of the JSP page * should be generated after this tag is finished. * Called from doEndTag(). * */ public boolean shouldEvaluateRestOfPageAfterEndTag() { return true; } //////////////////////////////////////////////////////////////// /// /// /// Tag Handler interface methods. /// /// /// /// Do not modify these methods; instead, modify the /// /// methods that they call. /// /// /// //////////////////////////////////////////////////////////////// /** .//GEN-BEGIN:doStartTag * * This method is called when the JSP engine encounters the start tag, * after the attributes are processed. * Scripting variables (if any) have their values set here. * @return EVAL_BODY_INCLUDE if the JSP engine should evaluate the tag body, otherwise return SKIP_BODY. * This method is automatically generated. Do not modify this method. * Instead, modify the methods that this method calls. * */ public int doStartTag() throws JspException, JspException { otherDoStartTagOperations(); if (theBodyShouldBeEvaluated()) { return EVAL_BODY_INCLUDE; } else { return SKIP_BODY; } }//GEN-END:doStartTag /** .//GEN-BEGIN:doEndTag * * * This method is called after the JSP engine finished processing the tag. * @return EVAL_PAGE if the JSP engine should continue evaluating the JSP page, otherwise return SKIP_PAGE. * This method is automatically generated. Do not modify this method. * Instead, modify the methods that this method calls. * */ public int doEndTag() throws JspException, JspException { otherDoEndTagOperations(); if (shouldEvaluateRestOfPageAfterEndTag()) { return EVAL_PAGE; } else { return SKIP_PAGE; } }//GEN-END:doEndTag public String getDefinitionName() { return definitionName; } public void setDefinitionName(String value) { definitionName = value; } public String getScreenName() { return screenName; } public void setScreenName(String value) { screenName = value; } }