Example usage for javax.servlet.jsp.tagext Tag EVAL_BODY_INCLUDE

List of usage examples for javax.servlet.jsp.tagext Tag EVAL_BODY_INCLUDE

Introduction

In this page you can find the example usage for javax.servlet.jsp.tagext Tag EVAL_BODY_INCLUDE.

Prototype

int EVAL_BODY_INCLUDE

To view the source code for javax.servlet.jsp.tagext Tag EVAL_BODY_INCLUDE.

Click Source Link

Document

Evaluate body into existing out stream.

Usage

From source file:org.parancoe.web.tag.MarkedPositionTagTest.java

/**
 * Test of doStartTagInternal method, of class MarkedPositionTag.
 *///from  w w w  . j  av a  2 s. c om
@Test
public void doStartTagInternal() throws Exception {
    String pathId = "testPathId";
    markPosition(pathId);
    MarkedPositionTag tag = new MarkedPositionTag();
    tag.setPageContext(pageContext);
    tag.setPathId(pathId);
    int result = tag.doStartTag();
    assertThat(result, equalTo(Tag.EVAL_BODY_INCLUDE));
    String output = ((MockHttpServletResponse) pageContext.getResponse()).getContentAsString();
    assertThat(output, equalTo("/test/forward/request/uri?p1=v1&p2=v2&p3=v3"));
}

From source file:com.googlecode.spring.appengine.taglib.IsLoggedInTag.java

@Override
public int doStartTag() throws JspException {
    boolean isLoggedIn = UserServiceFactory.getUserService().isUserLoggedIn();
    if (var != null) {
        pageContext.setAttribute(var, isLoggedIn, scope);
    }/*w  w w.  j av a  2 s . c  om*/
    return isLoggedIn ? Tag.EVAL_BODY_INCLUDE : Tag.SKIP_BODY;
}

From source file:com.googlecode.spring.appengine.taglib.IsNotLoggedInTag.java

@Override
public int doStartTag() throws JspException {
    boolean isNotLoggedIn = !UserServiceFactory.getUserService().isUserLoggedIn();
    if (var != null) {
        pageContext.setAttribute(var, isNotLoggedIn, scope);
    }/*from   w  ww  . j  a v  a  2s  . co  m*/
    return isNotLoggedIn ? Tag.EVAL_BODY_INCLUDE : Tag.SKIP_BODY;
}

From source file:com.googlecode.spring.appengine.taglib.IsAdminTag.java

@Override
public int doStartTag() throws JspException {
    UserService userService = UserServiceFactory.getUserService();
    boolean isAdmin = userService.isUserLoggedIn() ? userService.isUserAdmin() : false;
    if (var != null) {
        pageContext.setAttribute(var, isAdmin, scope);
    }// w w w .  j a  v  a2 s. com
    return isAdmin ? Tag.EVAL_BODY_INCLUDE : Tag.SKIP_BODY;
}

From source file:com.googlecode.spring.appengine.taglib.IsNotAdminTag.java

@Override
public int doStartTag() throws JspException {
    UserService userService = UserServiceFactory.getUserService();
    boolean isNotAdmin = userService.isUserLoggedIn() ? !userService.isUserAdmin() : true;
    if (var != null) {
        pageContext.setAttribute(var, isNotAdmin, scope);
    }//from   w  w  w .  j a  v a 2s.com
    return isNotAdmin ? Tag.EVAL_BODY_INCLUDE : Tag.SKIP_BODY;
}

From source file:com.googlecode.spring.appengine.taglib.IsProductionTag.java

@Override
public int doStartTag() throws JspException {
    boolean production = SystemProperty.environment.value() == SystemProperty.Environment.Value.Production;
    if (var != null) {
        pageContext.setAttribute(var, production, scope);
    }/*from   w w  w .  jav  a  2 s.  co  m*/
    return production ? Tag.EVAL_BODY_INCLUDE : Tag.SKIP_BODY;
}

From source file:com.googlecode.spring.appengine.taglib.IsDevelopmentTag.java

@Override
public int doStartTag() throws JspException {
    boolean development = SystemProperty.environment.value() == SystemProperty.Environment.Value.Development;
    if (var != null) {
        pageContext.setAttribute(var, development, scope);
    }//from  ww  w  . j av  a2s  .  c o m
    return development ? Tag.EVAL_BODY_INCLUDE : Tag.SKIP_BODY;
}

From source file:com.quatico.base.aem.test.api.setup.Tags.java

@Override
public String renderTag(TagSupport tag, PageContext pageContext, String body) throws Exception {
    StringWriter strWriter = new StringWriter();
    HttpServletResponse response = mock(HttpServletResponse.class);
    when(response.getWriter()).thenReturn(new PrintWriter(strWriter, true));

    if (!mockingDetails(pageContext).isSpy()) {
        pageContext = spy(pageContext);//w w w  . j a v a  2  s . com
    }

    JspWriter jspWriter = new JspWriterImpl(response);
    doReturn(jspWriter).when(pageContext).getOut();
    tag.setPageContext(pageContext);

    if (Tag.EVAL_BODY_INCLUDE == tag.doStartTag()) {
        jspWriter.flush();
        strWriter.write(body);
    }
    jspWriter.flush();
    tag.doEndTag();
    jspWriter.flush();
    tag.release();
    return strWriter.toString();
}

From source file:gov.nih.nci.cabig.caaers.web.tags.RenderDecisionManagerTag.java

@Override
public int doStartTag() throws JspException {
    //validate parameters
    validateParameters();/*from   ww  w .  j  a  v  a2s  . co m*/

    ApplicationContext appContext = WebApplicationContextUtils
            .getRequiredWebApplicationContext(pageContext.getServletContext());
    RenderDecisionManager renderDecisionManager = (RenderDecisionManager) appContext
            .getBean("renderDecisionManagerBean");

    boolean decision = false;
    if (uiType.equals(UI_TYPE_DIVISION)) {
        decision = renderDecisionManager.canRenderSection(elementID,
                (HttpServletRequest) pageContext.getRequest(), (HttpServletResponse) pageContext.getResponse());
    }
    if (uiType.equals(UI_TYPE_FIELD)) {
        decision = renderDecisionManager.canRenderField(elementID,
                (HttpServletRequest) pageContext.getRequest(), (HttpServletResponse) pageContext.getResponse());
    }

    return (decision) ? Tag.EVAL_BODY_INCLUDE : Tag.SKIP_BODY;
}

From source file:de.micromata.genome.gwiki.web.tags.GWikiAuthTag.java

@Override
public int doStartTag() throws JspException {
    GWikiContext ctx = getWikiContext();
    GWikiAuthorization auth = ctx.getWikiWeb().getAuthorization();

    if (StringUtils.isNotBlank(pageId) == true) {
        GWikiElementInfo pid = ctx.getWikiWeb().findElementInfo(pageId);
        if (pid == null || auth.isAllowToView(ctx, pid) == false) {
            return Tag.SKIP_BODY;
        }//from   w  w w .ja v  a2  s.  c  o m
        return Tag.EVAL_BODY_INCLUDE;
    }
    @SuppressWarnings("unused")
    GWikiElementInfo ei = ctx.getCurrentElement() != null ? ctx.getCurrentElement().getElementInfo() : null;
    /* The User must not have any if rights */
    if (StringUtils.isNotBlank(ifHasNot) == true) {
        for (String right : splitRights(ifHasNot)) {
            if (auth.isAllowTo(ctx, StringUtils.trim(right))) {
                return Tag.SKIP_BODY;
            }
        }
        return Tag.EVAL_BODY_INCLUDE;
    }

    /* The user must have all rights */
    if (StringUtils.isNotBlank(ifHasAll)) {

        boolean hasAll = true;
        for (String right : splitRights(ifHasAll)) {
            hasAll &= auth.isAllowTo(ctx, StringUtils.trim(right));
        }
        if (hasAll) {
            return Tag.EVAL_BODY_INCLUDE;
        }
        return Tag.SKIP_BODY;
    }

    if (StringUtils.isNotBlank(ifHasAny)) {

        for (String rigth : splitRights(ifHasAny)) {
            if (auth.isAllowTo(ctx, StringUtils.trim(rigth))) {
                return Tag.EVAL_BODY_INCLUDE;
            }
        }
        return Tag.SKIP_BODY;
    }
    return Tag.EVAL_BODY_INCLUDE;
}