Example usage for javax.servlet.jsp PageContext PAGE_SCOPE

List of usage examples for javax.servlet.jsp PageContext PAGE_SCOPE

Introduction

In this page you can find the example usage for javax.servlet.jsp PageContext PAGE_SCOPE.

Prototype

int PAGE_SCOPE

To view the source code for javax.servlet.jsp PageContext PAGE_SCOPE.

Click Source Link

Document

Page scope: (this is the default) the named reference remains available in this PageContext until the return from the current Servlet.service() invocation.

Usage

From source file:net.sourceforge.fenixedu.presentationTier.TagLib.content.ContentLinkTag.java

public static int getPageScope(final String scope) {
    if (scope == null) {
        return -1;
    } else if (scope.equalsIgnoreCase("page")) {
        return PageContext.PAGE_SCOPE;
    } else if (scope.equalsIgnoreCase("request")) {
        return PageContext.REQUEST_SCOPE;
    } else if (scope.equalsIgnoreCase("session")) {
        return PageContext.SESSION_SCOPE;
    } else {//from   w  w w  . ja  v  a  2 s  . c o  m
        return -1;
    }
}

From source file:com.googlecode.jtiger.modules.ecside.util.ExtremeUtils.java

/**
 * Get the bean out of the proper scope.
 *///from  w w w. j  ava 2 s  . c  o  m
public static Object retrieveFromScope(PageContext pageContext, String name, String scope) {
    if (StringUtils.isBlank(scope)) {
        return pageContext.findAttribute(name);
    }

    int scopeType = PageContext.REQUEST_SCOPE;

    if (scope.equalsIgnoreCase("page")) {
        scopeType = PageContext.PAGE_SCOPE;
    } else if (scope.equalsIgnoreCase("application")) {
        scopeType = PageContext.APPLICATION_SCOPE;
    } else if (scope.equalsIgnoreCase("session")) {
        scopeType = PageContext.SESSION_SCOPE;
    }

    return pageContext.getAttribute(name, scopeType);
}

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

@Test
@Verifies(value = "resolve a Tag with var not set to null", method = "doEndTag()")
public void doEndTag_shouldEvaluateVarIfIsNotNull() throws Exception {
    final String varName = "Mary";
    final String expectedOutput = "had a little lamb";
    openmrsMessageTag.setVar(varName);//from   w w  w .  j  a  v a  2 s . c o m
    DefaultMessageSourceResolvable message = new DefaultMessageSourceResolvable(new String[] { "test" },
            expectedOutput);
    openmrsMessageTag.setMessage(message);
    openmrsMessageTag.setScope(TagUtils.SCOPE_PAGE);

    checkDoEndTagEvaluationOfVar(varName, PageContext.PAGE_SCOPE, expectedOutput);
}

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

/**
 * Populates the variable in the specified scope. 
 * @param varValue// w w  w  . j a va  2s  .  c  o  m
 */
private void setVariable(boolean varValue) {

    if (var == null)
        return;

    int intScope = StringUtils.equals(scope, "request") ? PageContext.REQUEST_SCOPE
            : StringUtils.equals(scope, "session") ? PageContext.SESSION_SCOPE
                    : StringUtils.equals(scope, "application") ? PageContext.APPLICATION_SCOPE
                            : PageContext.PAGE_SCOPE;

    pageContext.setAttribute(getVar(), varValue, intScope);
}

From source file:net.sourceforge.fenixedu.presentationTier.TagLib.content.ContentLinkTag.java

protected int getPageToScope() {
    final String scope = getScope();
    final int pageScope = getPageScope(scope);
    return pageScope == -1 ? PageContext.PAGE_SCOPE : pageScope;
}

From source file:com.steeleforge.aem.ironsites.wcm.taglib.ModeHelperTag.java

protected void setupModeMap() {
    if (null == pageContext.getAttribute(getMapName(), PageContext.REQUEST_SCOPE)) {
        Map<String, Boolean> modeMap = new HashMap<String, Boolean>();

        // DISABLED, EDIT, PREVIEW, ANALYTICS, READ_ONLY, DESIGN
        modeMap.put(PROPERTY_DISABLED, WCMMode.DISABLED.equals(mode));
        modeMap.put(PROPERTY_DISABLED.toLowerCase(), WCMMode.DISABLED.equals(mode));

        modeMap.put(PROPERTY_EDIT, WCMMode.EDIT.equals(mode));
        modeMap.put(PROPERTY_EDIT.toLowerCase(), WCMMode.EDIT.equals(mode));

        modeMap.put(PROPERTY_PREVIEW, WCMMode.PREVIEW.equals(mode));
        modeMap.put(PROPERTY_PREVIEW.toLowerCase(), WCMMode.PREVIEW.equals(mode));

        modeMap.put(PROPERTY_ANALYTICS, WCMMode.ANALYTICS.equals(mode));
        modeMap.put(PROPERTY_ANALYTICS.toLowerCase(), WCMMode.ANALYTICS.equals(mode));

        modeMap.put(PROPERTY_READ_ONLY, WCMMode.READ_ONLY.equals(mode));
        modeMap.put(PROPERTY_READ_ONLY.toLowerCase(), WCMMode.READ_ONLY.equals(mode));

        modeMap.put(PROPERTY_DESIGN, WCMMode.DESIGN.equals(mode));
        modeMap.put(PROPERTY_DESIGN.toLowerCase(), WCMMode.DESIGN.equals(mode));

        pageContext.setAttribute(getMapName(), modeMap, PageContext.PAGE_SCOPE);
    }//from   ww  w  .j av  a2  s .  c  om
}

From source file:org.hdiv.web.servlet.tags.UrlTagTests.java

public void testVarDefaultScope() throws JspException {
    tag.setValue("url/path");
    tag.setVar("var");

    tag.doStartTag();/* w  w  w. ja  va  2s.  c  o m*/
    tag.doEndTag();

    String expectedValue = "/" + "url/path?" + this.hdivParameter;
    String actual = (String) context.getAttribute("var", PageContext.PAGE_SCOPE);
    assertTrue(actual.startsWith(expectedValue));
}

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

private static void assertValidScope(int scope, boolean allowSession, boolean allowApplication) {
    if ((scope < PageContext.PAGE_SCOPE) || (scope > PageContext.APPLICATION_SCOPE)) {
        throw new IllegalArgumentException("scope " + scope + " not supported");
    }//from   w w w  . j  a va  2s  . c  om
    if ((allowSession == false) && (scope == PageContext.SESSION_SCOPE)) {
        throw new IllegalArgumentException("session scope not supported");
    }
}

From source file:jp.terasoluna.fw.web.taglib.DefineCodeListTag.java

/**
 * ^O]Jn?\bh?B//from w  ww .ja  v a 2s.c o  m
 *
 * <p>
 * T?[ubgReLXg?AApplicationContext?A
 * &quot;page&quot; ?w id
 *  CodeListLoader ?A
 * R?[hXg pageContext o^?B
 *
 * R?[hXg???AArrayList
 *  pageContext o^?B
 * ?Ao^XR?[v &quot;page&quot; ??B
 * </p>
 *
 * @return ???w?B? EVAL_BODY_INCLUDE
 * @throws JspException JSP O
 */
@Override
public int doStartTag() throws JspException {
    if (log.isDebugEnabled()) {
        log.debug("doStartTag() called.");
    }

    if ("".equals(id)) {
        // id???
        log.error("id is required.");
        throw new JspTagException("id is required.");
    }
    // T?[ubgReLXg?AApplicationContext?B
    ServletContext sc = pageContext.getServletContext();
    ApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(sc);

    CodeListLoader loader = null;

    try {
        loader = (CodeListLoader) context.getBean(id);
    } catch (ClassCastException e) {
        //BeanCodeListLoaderOX??[
        String errorMessage = "bean id:" + id + " is not instance of CodeListLoader.";
        log.error(errorMessage);
        throw new JspTagException(errorMessage, e);
    }

    // ?P?[
    Locale locale = RequestUtils.getUserLocale((HttpServletRequest) pageContext.getRequest(),
            Globals.LOCALE_KEY);

    CodeBean[] codeBeanArray = loader.getCodeBeans(locale);
    if (codeBeanArray == null) {
        // codeBeanListnull??ArrayList??B
        if (log.isWarnEnabled()) {
            log.warn("Codebean is null. CodeListLoader(bean id:" + id + ")");
        }
        pageContext.setAttribute(id, new ArrayList(), PageContext.PAGE_SCOPE);
    } else {
        // R?[hXgo^?B
        pageContext.setAttribute(id, codeBeanArray, PageContext.PAGE_SCOPE);
    }

    return EVAL_BODY_INCLUDE;
}

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

@Override
public int getAttributesScope(String key) {
    if (pageAttributes.containsKey(key) == true)
        return PageContext.PAGE_SCOPE;
    if (contains(request.getAttributeNames(), key) == true)
        return PageContext.REQUEST_SCOPE;
    if (session != null) {
        if (contains(session.getAttributeNames(), key) == true) {
            return PageContext.SESSION_SCOPE;
        }//  w  w w .j a  v  a  2s  .  co m
    }
    if (contains(servletCtx.getAttributeNames(), key) == true)
        return PageContext.APPLICATION_SCOPE;
    return 0;
}