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

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

Introduction

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

Prototype


void setBodyContent(BodyContent b);

Source Link

Document

Set the bodyContent property.

Usage

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

/**
 * @return true if body should be included
 *//*from  w  w w . j  ava  2 s  .  c om*/
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.
 * //  www . java2 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 setBodyContent(CycleWriter body) {
    if (body == null) {
        throw new IllegalArgumentException();
    }/*from  w w w.  j a  va2  s .  c  om*/
    Tag tag = getLoadedTag();
    if (tag instanceof BodyTag) {
        BodyTag bodyTag = (BodyTag) tag;
        bodyTag.setBodyContent(new BodyContentImpl(body));
    } else {
        throw new IllegalStateException();
    }
}