Java Code Examples for javax.servlet.jsp.tagext.BodyTagSupport#EVAL_BODY_AGAIN

The following examples show how to use javax.servlet.jsp.tagext.BodyTagSupport#EVAL_BODY_AGAIN . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ListTag.java    From uyuni with GNU General Public License v2.0 6 votes vote down vote up
/**
 * ${@inheritDoc}
 */
@Override
public int doAfterBody() throws JspException {
    int retval = BodyTagSupport.EVAL_BODY_AGAIN;

    ListCommand nextCmd = getNextCommand();

    switch (nextCmd) {
        case TBL_HEADING:    doAfterBodyRenderListBegin(); break;
        case TBL_ADDONS:     doAfterBodyRenderTopAddons(); break;
        case COL_HEADER:     doAfterBodyRenderColHeaders(); break;
        case BEFORE_RENDER:  retval = doAfterBodyRenderBeforeData(); break;
        case RENDER:         retval = doAfterBodyRenderData(); break;
        case AFTER_RENDER:   retval = doAfterBodyRenderAfterData(); break;
        case TBL_FOOTER:     retval = doAfterBodyRenderFooterAddons(); break;
        default: break;
    }
    return retval;
}
 
Example 2
Source File: ListTag.java    From spacewalk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * ${@inheritDoc}
 */
@Override
public int doAfterBody() throws JspException {
    int retval = BodyTagSupport.EVAL_BODY_AGAIN;

    ListCommand nextCmd = getNextCommand();

    switch (nextCmd) {
        case TBL_HEADING:    doAfterBodyRenderListBegin(); break;
        case TBL_ADDONS:     doAfterBodyRenderTopAddons(); break;
        case COL_HEADER:     doAfterBodyRenderColHeaders(); break;
        case BEFORE_RENDER:  retval = doAfterBodyRenderBeforeData(); break;
        case RENDER:         retval = doAfterBodyRenderData(); break;
        case AFTER_RENDER:   retval = doAfterBodyRenderAfterData(); break;
        case TBL_FOOTER:     retval = doAfterBodyRenderFooterAddons(); break;
        default: break;
    }
    return retval;
}
 
Example 3
Source File: ListTag.java    From uyuni with GNU General Public License v2.0 5 votes vote down vote up
private int doAfterBodyRenderData() throws JspException {
    // if there was a previous object, close its row
    if (currentObject != null) {
        ListTagUtil.write(pageContext, "</tr>");
    }

    ListTagUtil.setCurrentCommand(pageContext, getUniqueName(),
            ListCommand.RENDER);

    if (iterator.hasNext()) {
        Object obj = iterator.next();
        if (RhnListTagFunctions.isExpandable(obj)) {
            parentObject = obj;
        }
        currentObject = obj;
    }
    else {
        currentObject = null;
    }

    if (currentObject != null) {
        ListTagUtil.write(pageContext, "<tr");
        renderRowClassAndId();

        ListTagUtil.write(pageContext, ">");
        pageContext.setAttribute(rowName, currentObject);
    }
    else  {
        return doAfterBodyRenderAfterData();
    }
    return BodyTagSupport.EVAL_BODY_AGAIN;
}
 
Example 4
Source File: JSPPageExecuter.java    From ontopia with Apache License 2.0 5 votes vote down vote up
private void loopTag(TagSupport tag, JSPTreeNodeIF curNode)
  throws JspException, IOException {
  // loop as long as tag says so
  int token;
  do {
    runTag(tag, curNode);
    token = tag.doAfterBody();
  } while (token == BodyTagSupport.EVAL_BODY_AGAIN);
  if (token != BodyTagSupport.SKIP_BODY)
    throw new OntopiaRuntimeException("Internal error: unknown doAfterBody token: " + token);
}
 
Example 5
Source File: ListTag.java    From spacewalk with GNU General Public License v2.0 5 votes vote down vote up
private int doAfterBodyRenderData() throws JspException {
    // if there was a previous object, close its row
    if (currentObject != null) {
        ListTagUtil.write(pageContext, "</tr>");
    }

    ListTagUtil.setCurrentCommand(pageContext, getUniqueName(),
            ListCommand.RENDER);

    if (iterator.hasNext()) {
        Object obj = iterator.next();
        if (RhnListTagFunctions.isExpandable(obj)) {
            parentObject = obj;
        }
        currentObject = obj;
    }
    else {
        currentObject = null;
    }

    if (currentObject != null) {
        ListTagUtil.write(pageContext, "<tr");
        renderRowClassAndId();

        ListTagUtil.write(pageContext, ">");
        pageContext.setAttribute(rowName, currentObject);
    }
    else  {
        return doAfterBodyRenderAfterData();
    }
    return BodyTagSupport.EVAL_BODY_AGAIN;
}
 
Example 6
Source File: ListTag.java    From uyuni with GNU General Public License v2.0 4 votes vote down vote up
private int doAfterBodyRenderAfterData() throws JspException {
    ListTagUtil.setCurrentCommand(pageContext, getUniqueName(),
            ListCommand.AFTER_RENDER);
    ListTagUtil.write(pageContext, "</tbody>");
    return BodyTagSupport.EVAL_BODY_AGAIN;
}
 
Example 7
Source File: ListTagTest.java    From uyuni with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Tests normal conditions for ListTag.
 * @throws Exception something bad happened
 */
public void testRegularRun() throws Exception {
    context().checking(new Expectations() { {
        atLeast(1).of(req).getRequestURI();
        will(returnValue("UTF-8"));

        atLeast(1).of(req).getAttribute("session");
        will(returnValue(webSess));

        atLeast(1).of(webSess).getWebUserId();
        will(returnValue(null));

        atLeast(1).of(req).getParameter(with(containsString("list_")));
        will(returnValue(null));

        atLeast(1).of(req).setAttribute(
                with(equal("pageNum")),
                with(any(String.class)));

        atLeast(1).of(req).setAttribute(
                with(equal("dataSize")),
                with(any(String.class)));

        atLeast(1).of(pageContext).getOut();
        will(returnValue(writer));

        atLeast(1).of(pageContext).setAttribute(
                with(containsString("_cmd")),
                with(any(Object.class)));

        atLeast(1).of(pageContext).setAttribute(
                with(equal("current")),
                with(any(Object.class)));

        atLeast(1).of(pageContext).getAttribute("current");
        will(returnValue(null));

        atLeast(1).of(pageContext).pushBody(with(any(Writer.class)));

        atLeast(1).of(pageContext).popBody();

        atLeast(1).of(req)
                .getParameter(with(containsString("PAGE_SIZE_LABEL_SELECTED")));
        will(returnValue(null));
    } });

    final Action[] cmdValues = {
            returnValue(ListCommand.ENUMERATE), // listtag asking
            returnValue(ListCommand.ENUMERATE), // columntag asking
            returnValue(ListCommand.TBL_HEADING), // listtag asking
            returnValue(ListCommand.TBL_HEADING), // columntag asking
            returnValue(ListCommand.TBL_ADDONS), // listtag asking
            returnValue(ListCommand.TBL_ADDONS), // columntag asking
            returnValue(ListCommand.COL_HEADER), // listtag asking
            returnValue(ListCommand.COL_HEADER), // columntag asking
            returnValue(ListCommand.BEFORE_RENDER), // listtag asking
            returnValue(ListCommand.BEFORE_RENDER), // columntag asking
            returnValue(ListCommand.RENDER),    // listtag asking
            returnValue(ListCommand.RENDER),    // columntag asking
            returnValue(ListCommand.AFTER_RENDER), // listtag asking
            returnValue(ListCommand.AFTER_RENDER), // columntag asking
            returnValue(ListCommand.TBL_FOOTER), // listtag asking
            returnValue(ListCommand.TBL_FOOTER) // columntag asking
    };

    context().checking(new Expectations() { {
        atLeast(1).of(pageContext).getAttribute(with(containsString("_cmd")));
        will(onConsecutiveCalls(cmdValues));
    } });

    int tagval = lt.doStartTag();

    assertEquals(BodyTagSupport.EVAL_BODY_INCLUDE, tagval);
    do {
        tagval = lt.doAfterBody();
    } while (tagval == BodyTagSupport.EVAL_BODY_AGAIN);
    tagval = lt.doEndTag();
    assertEquals(BodyTagSupport.EVAL_PAGE, tagval);
}
 
Example 8
Source File: ListTag.java    From spacewalk with GNU General Public License v2.0 4 votes vote down vote up
private int doAfterBodyRenderAfterData() throws JspException {
    ListTagUtil.setCurrentCommand(pageContext, getUniqueName(),
            ListCommand.AFTER_RENDER);
    ListTagUtil.write(pageContext, "</tbody>");
    return BodyTagSupport.EVAL_BODY_AGAIN;
}
 
Example 9
Source File: ListTagTest.java    From spacewalk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Tests normal conditions for ListTag.
 * @throws Exception something bad happened
 */
public void testRegularRun() throws Exception {
    context().checking(new Expectations() { {
        atLeast(1).of(req).getRequestURI();
        will(returnValue("UTF-8"));

        atLeast(1).of(req).getAttribute("session");
        will(returnValue(webSess));

        atLeast(1).of(webSess).getWebUserId();
        will(returnValue(null));

        atLeast(1).of(req).getParameter(with(containsString("list_")));
        will(returnValue(null));

        atLeast(1).of(req).setAttribute(
                with(equal("pageNum")),
                with(any(String.class)));

        atLeast(1).of(req).setAttribute(
                with(equal("dataSize")),
                with(any(String.class)));

        atLeast(1).of(pageContext).getOut();
        will(returnValue(writer));

        atLeast(1).of(pageContext).setAttribute(
                with(containsString("_cmd")),
                with(any(Object.class)));

        atLeast(1).of(pageContext).setAttribute(
                with(equal("current")),
                with(any(Object.class)));

        atLeast(1).of(pageContext).getAttribute("current");
        will(returnValue(null));

        atLeast(1).of(pageContext).pushBody(with(any(Writer.class)));

        atLeast(1).of(pageContext).popBody();

        atLeast(1).of(req)
                .getParameter(with(containsString("PAGE_SIZE_LABEL_SELECTED")));
        will(returnValue(null));
    } });

    final Action[] cmdValues = {
            returnValue(ListCommand.ENUMERATE), // listtag asking
            returnValue(ListCommand.ENUMERATE), // columntag asking
            returnValue(ListCommand.TBL_HEADING), // listtag asking
            returnValue(ListCommand.TBL_HEADING), // columntag asking
            returnValue(ListCommand.TBL_ADDONS), // listtag asking
            returnValue(ListCommand.TBL_ADDONS), // columntag asking
            returnValue(ListCommand.COL_HEADER), // listtag asking
            returnValue(ListCommand.COL_HEADER), // columntag asking
            returnValue(ListCommand.BEFORE_RENDER), // listtag asking
            returnValue(ListCommand.BEFORE_RENDER), // columntag asking
            returnValue(ListCommand.RENDER),    // listtag asking
            returnValue(ListCommand.RENDER),    // columntag asking
            returnValue(ListCommand.AFTER_RENDER), // listtag asking
            returnValue(ListCommand.AFTER_RENDER), // columntag asking
            returnValue(ListCommand.TBL_FOOTER), // listtag asking
            returnValue(ListCommand.TBL_FOOTER) // columntag asking
    };

    context().checking(new Expectations() { {
        atLeast(1).of(pageContext).getAttribute(with(containsString("_cmd")));
        will(onConsecutiveCalls(cmdValues));
    } });

    int tagval = lt.doStartTag();

    assertEquals(BodyTagSupport.EVAL_BODY_INCLUDE, tagval);
    do {
        tagval = lt.doAfterBody();
    } while (tagval == BodyTagSupport.EVAL_BODY_AGAIN);
    tagval = lt.doEndTag();
    assertEquals(BodyTagSupport.EVAL_PAGE, tagval);
}