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

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

Introduction

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

Prototype

int SKIP_PAGE

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

Click Source Link

Document

Skip the rest of the page.

Usage

From source file:org.openmrs.web.taglib.RequireTagTest.java

/**
 * @see RequireTag#doStartTag()/* ww w. j  av a2s  .c  o  m*/
 */
@Test
@SkipBaseSetup
@Verifies(value = "should reject user without all of the privileges", method = "doStartTag()")
public void doStartTag_shouldRejectUserWithoutAllOfThePrivileges() throws Exception {
    initializeInMemoryDatabase();
    executeDataSet("org/openmrs/web/taglib/include/RequireTagTest.xml");
    Context.authenticate("whirleygiguser", "test");

    RequireTag tag = new RequireTag();
    tag.setPageContext(new MockPageContext());
    tag.setAllPrivileges("Manage WhirleyGigs, Manage WhoopDeDoos, Manage Thingamajigs");

    // the tag passes
    Assert.assertEquals(Tag.SKIP_PAGE, tag.doStartTag());

    Context.logout();
}

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

/**
 * @return if return false page will be skipped
 *//*from w  w  w.j a v  a  2  s. c  o  m*/
public static boolean initSimpleTag(Tag tag, List<Object> attributes, ChildPageContext ctx) throws Exception {
    if (log.isDebugEnabled())
        log.debug("Init simple tag: " + tag.getClass().getName());
    Tag ptag = ctx.getCurrentTag();
    PageContext pctx = ctx;// .getBrickContext().getPageContext();
    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));
    r = tag.doEndTag();
    // ctx.getTagStack().pop();
    ctx.setCurrentTag(ptag);
    return r != javax.servlet.jsp.tagext.Tag.SKIP_PAGE;
}

From source file:org.openmrs.web.taglib.RequireTagTest.java

/**
 * @see RequireTag#doStartTag()/*ww  w .  j ava 2s. c o m*/
 */
@Test
@SkipBaseSetup
@Verifies(value = "should reject user without any of the privileges", method = "doStartTag()")
public void doStartTag_shouldRejectUserWithoutAnyOfThePrivileges() throws Exception {
    initializeInMemoryDatabase();
    executeDataSet("org/openmrs/web/taglib/include/RequireTagTest.xml");
    Context.authenticate("whirleygiguser", "test");

    RequireTag tag = new RequireTag();
    tag.setPageContext(new MockPageContext());
    tag.setAnyPrivilege("Random Privilege, Other Random Privilege");

    // the tag passes
    Assert.assertEquals(Tag.SKIP_PAGE, tag.doStartTag());

    Context.logout();
}

From source file:org.openmrs.web.taglib.RequireTagTest.java

/**
 * @see RequireTag#doStartTag()/*from ww w . j a v  a  2s . c  om*/
 */
@Test
@SkipBaseSetup
@Verifies(value = "should reject user without the privilege", method = "doStartTag()")
public void doStartTag_shouldRejectUserWithoutThePrivilege() throws Exception {
    initializeInMemoryDatabase();
    executeDataSet("org/openmrs/web/taglib/include/RequireTagTest.xml");
    Context.authenticate("overallmanager", "test");

    RequireTag tag = new RequireTag();
    tag.setPageContext(new MockPageContext());
    tag.setPrivilege("Some Random Privilege");

    // the tag passes
    Assert.assertEquals(Tag.SKIP_PAGE, tag.doStartTag());

    Context.logout();
}

From source file:org.openmrs.web.taglib.RequireTagTest.java

/**
 * @see RequireTag#doStartTag()//w  w  w  .  java  2  s.c  o m
 */
@Test
@SkipBaseSetup
@Verifies(value = "should set the right session attributes if the authenticated user misses some privileges", method = "doStartTag()")
public void doStartTag_shouldSetTheRightSessionAttributesIfTheAuthenticatedUserMissesSomePrivileges()
        throws Exception {
    initializeInMemoryDatabase();
    executeDataSet("org/openmrs/web/taglib/include/RequireTagTest.xml");
    Context.authenticate("whirleygiguser", "test");

    RequireTag tag = new RequireTag();
    MockPageContext pageContext = new MockPageContext();
    final String referer = "/denied.htm";
    ((MockHttpServletRequest) pageContext.getRequest()).addHeader("Referer", referer);
    tag.setPageContext(pageContext);
    tag.setAllPrivileges("Manage WhirleyGigs,Manage Thingamajigs");
    String redirect = "/myRedirect.html";
    tag.setRedirect(redirect);

    Assert.assertEquals(Tag.SKIP_PAGE, tag.doStartTag());
    Assert.assertEquals(true,
            pageContext.getAttribute(WebConstants.INSUFFICIENT_PRIVILEGES, PageContext.SESSION_SCOPE));
    Assert.assertNotNull(pageContext.getAttribute(WebConstants.REQUIRED_PRIVILEGES, PageContext.SESSION_SCOPE));
    Assert.assertEquals(redirect,
            pageContext.getAttribute(WebConstants.DENIED_PAGE, PageContext.SESSION_SCOPE).toString());

    Context.logout();
}

From source file:org.openmrs.web.taglib.RequireTagTest.java

/**
 * @see RequireTag#doStartTag()/*from ww  w .  j  a  v a 2 s  .  c  o  m*/
 */
@Test
@SkipBaseSetup
@Verifies(value = "should set the referer as the denied page url if no redirect url is specified", method = "doStartTag()")
public void doStartTag_shouldSetTheRefererAsTheDeniedPageUrlIfNoRedirectUrlIsSpecified() throws Exception {
    initializeInMemoryDatabase();
    executeDataSet("org/openmrs/web/taglib/include/RequireTagTest.xml");
    Context.authenticate("whirleygiguser", "test");

    RequireTag tag = new RequireTag();
    MockPageContext pageContext = new MockPageContext();
    final String referer = "/denied.htm";
    ((MockHttpServletRequest) pageContext.getRequest()).addHeader("Referer", referer);
    tag.setPageContext(pageContext);
    tag.setAllPrivileges("Manage WhirleyGigs,Manage Thingamajigs");
    tag.setRedirect("");

    Assert.assertEquals(Tag.SKIP_PAGE, tag.doStartTag());
    Assert.assertEquals(true,
            pageContext.getAttribute(WebConstants.INSUFFICIENT_PRIVILEGES, PageContext.SESSION_SCOPE));
    Assert.assertNotNull(pageContext.getAttribute(WebConstants.REQUIRED_PRIVILEGES, PageContext.SESSION_SCOPE));
    Assert.assertEquals(referer,
            pageContext.getAttribute(WebConstants.DENIED_PAGE, PageContext.SESSION_SCOPE).toString());

    Context.logout();
}

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

/**
 * @return true if continue/*from  www  . ja  v a  2 s  .c o m*/
 */
public static boolean endTag(ChildPageContext ctx) throws Exception {
    Pair<Tag, Integer> tt = ctx.getTagStack().pop();
    Tag t = tt.getFirst();
    int r = t.doEndTag();
    if (ctx.getTagStack().size() > 0)
        ctx.setCurrentTag(ctx.getTagStack().lastElement().getFirst());
    else
        ctx.setCurrentTag(null);
    boolean ret = r != javax.servlet.jsp.tagext.Tag.SKIP_PAGE;
    if (log.isDebugEnabled() == true)
        log.debug("endTag: " + t.getClass().getName() + ": " + ret);
    return ret;
}

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

protected ProcessStatus getProcessStatus(int status, boolean doStart) {
    if (status == Tag.EVAL_BODY_INCLUDE) {
        return _forceBodySkip ? ProcessStatus.SKIP_BODY : ProcessStatus.EVAL_BODY_INCLUDE;
    } else if (status == Tag.SKIP_BODY) {
        return ProcessStatus.SKIP_BODY;
    } else if (status == Tag.EVAL_PAGE) {
        return ProcessStatus.EVAL_PAGE;
    } else if (status == Tag.SKIP_PAGE) {
        return ProcessStatus.SKIP_PAGE;
    } else if (!doStart && status == IterationTag.EVAL_BODY_AGAIN) {
        return ProcessStatus.EVAL_BODY_AGAIN;
    } else if (doStart && status == BodyTag.EVAL_BODY_BUFFERED) {
        return _forceBodySkip ? ProcessStatus.SKIP_BODY : ProcessStatus.EVAL_BODY_BUFFERED;
    }//w  ww  .j  av a 2s.co  m
    throw new IllegalArgumentException();
}