Example usage for javax.servlet.jsp.tagext BodyTag doInitBody

List of usage examples for javax.servlet.jsp.tagext BodyTag doInitBody

Introduction

In this page you can find the example usage for javax.servlet.jsp.tagext BodyTag doInitBody.

Prototype


void doInitBody() throws JspException;

Source Link

Document

Prepare for evaluation of the body.

Usage

From source file:de.micromata.genome.gwiki.page.gspt.TagSupport.java

/**
 * @return true if body should be included
 *//*  w w w.  java 2  s  . c o m*/
public static boolean initTag(Tag tag, List<Object> attributes, ChildPageContext ctx) throws Exception {
    Tag ptag = ctx.getCurrentTag();
    if (log.isDebugEnabled())
        log.debug("Init tag: " + tag.getClass().getName());

    PageContext pctx = ctx;
    if (ctx.isUseParentTagContext() == true)
        pctx = ctx.getParentPageContext();
    tag.setPageContext(pctx);
    tag.setParent(ptag);
    attributes = evalAttributes(tag, attributes, ctx);
    setAttributes(tag, attributes, ctx);
    ctx.setCurrentTag(tag);
    int r = tag.doStartTag();
    ctx.getTagStack().push(new Pair<Tag, Integer>(tag, r));
    JspWriter oout = pctx.getOut();
    ctx.setInternalGroovyOut(createPrintWriter(oout));
    if (r != javax.servlet.jsp.tagext.Tag.SKIP_BODY && r != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE
            && tag instanceof BodyTag) {

        BodyTag btag = (BodyTag) tag;

        JspWriter out = pctx.pushBody();
        PrintWriterPatched newPout = createPrintWriter(out, true);
        ctx.setInternalGroovyOut(newPout);

        btag.setBodyContent((javax.servlet.jsp.tagext.BodyContent) out);
        btag.doInitBody();
    }
    boolean ret = r != javax.servlet.jsp.tagext.Tag.SKIP_BODY;
    if (log.isDebugEnabled())
        log.debug("Init tag: " + tag.getClass().getName() + ": " + ret);
    return ret;
}

From source file:org.apache.cactus.extension.jsp.JspTagLifecycle.java

/**
 * Internal method to invoke a tag without doing exception handling.
 * //from  w w w . j av a 2 s .  c  o m
 * @throws JspException If the tag throws an exception
 * @throws IOException If an error occurs when reading or writing the body
 *         content
 */
private void invokeInternal() throws JspException, IOException {
    int status = this.tag.doStartTag();
    if (this.tag instanceof IterationTag) {
        if (status != Tag.SKIP_BODY) {
            BodyContent body = null;
            try {
                IterationTag iterationTag = (IterationTag) this.tag;
                if ((status == BodyTag.EVAL_BODY_BUFFERED) && (this.tag instanceof BodyTag)) {
                    BodyTag bodyTag = (BodyTag) this.tag;
                    body = pageContext.pushBody();
                    if (log.isDebugEnabled()) {
                        log.debug("Pushed body content [" + body.getString() + "]");
                    }
                    bodyTag.setBodyContent(body);
                    bodyTag.doInitBody();
                }
                int iteration = 0;
                do {
                    fireEvalBody(iteration, body);
                    if (log.isDebugEnabled()) {
                        log.debug("Body evaluated for the [" + iteration + "] time");
                    }
                    status = iterationTag.doAfterBody();
                    iteration++;
                } while (status == IterationTag.EVAL_BODY_AGAIN);
                if (log.isDebugEnabled()) {
                    log.debug("Body skipped");
                }
                fireSkipBody();
            } finally {
                if (body != null) {
                    if (log.isDebugEnabled()) {
                        log.debug("Popping body content [" + body.getString() + "]");
                    }
                    pageContext.popBody();
                    body = null;
                }
            }
        } else {
            if (log.isDebugEnabled()) {
                log.debug("Body skipped");
            }
            fireSkipBody();
        }
    }
    status = tag.doEndTag();
}

From source file:org.seasar.mayaa.impl.engine.processor.JspProcessor.java

public void doInitChildProcess() {
    Tag tag = getLoadedTag();/*from  w  ww.  ja v a2s  .c  o m*/
    if (tag instanceof BodyTag) {
        BodyTag bodyTag = (BodyTag) tag;
        try {
            bodyTag.doInitBody();
        } catch (JspException e) {
            throw createJspRuntimeException(getOriginalNode(), getInjectedNode(), e);
        }
    } else {
        throw new IllegalStateException();
    }
}