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 javax.servlet.jsp.JspTagException; /** * Generated tag class. */ public class InsertTag extends TagSupport { /** property declaration for tag attribute: definitionName. */ private String definitionName; /** property declaration for tag attribute: parameterName. */ private String parameterName; private boolean directInclude = false; private Definition definition = null; private Parameter parameter = null; public InsertTag() { 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() { // // TODO: code that performs other operations in doStartTag // should be placed here. // It will be called after initializing variables, // finding the parent, setting IDREFs, etc, and // before calling theBodyShouldBeEvaluated(). // // For example, to print something out to the JSP, use the following: // // try { // JspWriter out = pageContext.getOut(); // out.println("something"); // } catch (java.io.IOException ex) { // // do something // } // // } /** * * Fill in this method to determine if the tag body should be evaluated * Called from doStartTag(). * */ public boolean theBodyShouldBeEvaluated() { definition = (Definition)pageContext.getAttribute(definitionName); // get the parameter if (parameterName != null && definition != null) parameter = (Parameter) definition.getParam(parameterName); if (parameter != null) directInclude = parameter.isDirect(); return false; } // // methods called from doEndTag() // /** * * Fill in this method to perform other operations from doEndTag(). * */ public void otherDoEndTagOperations() throws JspTagException { try { // if parameter is direct, print to out if (directInclude && parameter != null) pageContext.getOut().print(parameter.getValue()); // if parameter is indirect, include results of dispatching to page else { if ((parameter != null) && (parameter.getValue() != null)) pageContext.include(parameter.getValue()); } } catch (Exception ex) { throw new JspTagException(ex.getMessage()); } } /** * * 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 getParameterName() { return parameterName; } public void setParameterName(String value) { parameterName = value; } }