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:de.micromata.genome.gwiki.page.gspt.ServletStandalonePageContext.java

@Override
public void setAttribute(String key, Object value, int scope) {
    if (value == null) {
        removeAttribute(key, scope);//from ww w .j  av  a2s  .co  m
        return;
    }
    switch (scope) {
    case PageContext.PAGE_SCOPE:
        pageAttributes.put(key, value);
        break;
    case PageContext.REQUEST_SCOPE:
        request.setAttribute(key, value);
        break;
    case PageContext.SESSION_SCOPE:
        if (session != null) {
            session.setAttribute(key, value);
        }
        break;
    case PageContext.APPLICATION_SCOPE:
        servletCtx.setAttribute(key, value);
        break;
    default:

        break;
    }
}

From source file:eionet.cr.util.Util.java

/**
 *
 * @param pageContext/*from w w  w .j av a 2s  .  c  o  m*/
 * @param objectClass
 * @return
 */
public static Object findInAnyScope(PageContext pageContext, Class objectClass) {

    if (pageContext == null || objectClass == null) {
        return null;
    }

    int[] scopes = { PageContext.APPLICATION_SCOPE, PageContext.PAGE_SCOPE, PageContext.REQUEST_SCOPE,
            PageContext.SESSION_SCOPE };
    for (int i = 0; i < scopes.length; i++) {
        Enumeration attrs = pageContext.getAttributeNamesInScope(scopes[i]);
        while (attrs != null && attrs.hasMoreElements()) {
            String name = (String) attrs.nextElement();
            Object o = pageContext.getAttribute(name, scopes[i]);
            if (o != null && objectClass.isInstance(o)) {
                return o;
            }
        }
    }

    return null;
}

From source file:com.rainbow.fw.web.taglib.CodeListTag.java

/**
 * ??/*from  w  w w.  jav a  2s . co  m*/
 * 
 * <p>
 * ??ApplicationContext??? &quot;page&quot; ??? id ?
 * CodeListLoader ???????  pageContext ??
 * 
 * ?????????ArrayList pageContext ?? ?????
 * &quot;page&quot; ??
 * </p>
 * 
 * @return ?? EVAL_BODY_INCLUDE
 * @throws JspException
 *             JSP 
 */
@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.");
    }

    // ?ApplicationContext??
    ServletContext sc = pageContext.getServletContext();

    ApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(sc);

    CodeListLoader loader = null;

    if (null == codeDefineList) {
        try {
            loader = ContextProvider.getBean(CodeListLoader.class);

        } catch (ClassCastException e) {
            // ???Bean?CodeListLoader??????
            String errorMessage = "bean id:" + id + " is not instance of CodeListLoader.";
            log.error(errorMessage);
            throw new JspTagException(errorMessage, e);
        }
        codeDefineList = loader.getCodeBeans(id);
    }
    // List<CodeDefine> codeDefineList = loader.getCodeBeans(id);

    Map<String, String> cardType = new LinkedHashMap<String, String>();

    for (CodeDefine codeDefine : codeDefineList) {
        cardType.put(codeDefine.getCodeValue(), codeDefine.getCodeKey());
    }

    cardType = Collections.unmodifiableMap(cardType);

    if (cardType == null) {
        // codeBeanList?null???ArrayList?
        if (log.isWarnEnabled()) {
            log.warn("Codebean is null. CodeListLoader(bean id:" + id + ")");
        }
        pageContext.setAttribute(id, new ArrayList(), PageContext.PAGE_SCOPE);
    } else {
        // ?
        pageContext.setAttribute(id, cardType, PageContext.PAGE_SCOPE);
    }

    return EVAL_BODY_INCLUDE;
}

From source file:com.geemvc.taglib.GeemvcTagSupport.java

protected Object attribute(String name) {
    Object bean = jspContext.getAttribute(name, PageContext.PAGE_SCOPE);

    if (bean == null)
        bean = jspContext.getAttribute(name, PageContext.REQUEST_SCOPE);

    if (bean == null)
        bean = jspContext.getAttribute(name, PageContext.SESSION_SCOPE);

    return bean;//from w  ww.j  a  va  2 s  . c o  m
}

From source file:info.magnolia.cms.taglibs.util.SimpleSearchTag.java

/**
 * @see javax.servlet.jsp.tagext.TagSupport#release()
 *///w w  w. java2 s. c  om
public void release() {
    this.query = null;
    this.var = null;
    this.scope = PageContext.PAGE_SCOPE;
    this.startLevel = 0;
    super.release();
}

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

@Override
public void removeAttribute(String key, int scope) {
    switch (scope) {
    case PageContext.PAGE_SCOPE:
        pageAttributes.remove(key);/* ww  w . j av a  2  s . c om*/
        break;
    case PageContext.REQUEST_SCOPE:
        request.removeAttribute(key);
        break;
    case PageContext.SESSION_SCOPE:
        if (session != null) {
            session.removeAttribute(key);
        }
        break;
    case PageContext.APPLICATION_SCOPE:
        servletCtx.removeAttribute(key);
        break;
    default:
        break;
    }
}

From source file:info.magnolia.cms.taglibs.ContentNodeIterator.java

/**
 * @see javax.servlet.jsp.tagext.Tag#doEndTag()
 *//*from ww  w  . jav  a2 s . com*/
public int doEndTag() {

    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

    Resource.removeLocalContentNode(request);
    Resource.removeLocalContentNodeCollectionName(request);

    pageContext.removeAttribute(ContentNodeIterator.CURRENT_INDEX);
    pageContext.removeAttribute(ContentNodeIterator.SIZE);
    pageContext.removeAttribute(ContentNodeIterator.CONTENT_NODE_COLLECTION_NAME);

    this.size = 0;
    this.index = 0;
    this.current = null;

    if (varStatus != null) {
        pageContext.removeAttribute(varStatus, PageContext.PAGE_SCOPE);
    }

    return EVAL_PAGE;
}

From source file:info.magnolia.cms.taglibs.Out.java

/**
 * @see javax.servlet.jsp.tagext.TagSupport#release()
 *///from   w  w  w. jav  a  2 s . c o  m
public void release() {
    super.release();

    this.fileProperty = StringUtils.EMPTY;
    this.datePattern = DEFAULT_DATEPATTERN;
    this.dateLanguage = null;
    this.lineBreak = DEFAULT_LINEBREAK;
    this.var = null;
    this.scope = PageContext.PAGE_SCOPE;
}

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

@Override
public void setAttribute(String key, Object value) {
    setAttribute(key, value, PageContext.PAGE_SCOPE);
}

From source file:com.redhat.rhn.frontend.taglibs.list.ColumnTag.java

protected void renderUnbound() throws JspException {
    ListTag parent = (ListTag) BodyTagSupport.findAncestorWithClass(this, ListTag.class);
    if (attributeName != null) {
        Object bean = parent.getCurrentObject();
        String value = ListTagUtil.getBeanValue(bean, attributeName);
        pageContext.setAttribute("beanValue", value, PageContext.PAGE_SCOPE);
    }/*  w  w  w .j a va 2 s . c  om*/
    writeStartingTd();
}