Example usage for javax.servlet.jsp PageContext getAttribute

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

Introduction

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

Prototype


abstract public Object getAttribute(String name, int scope);

Source Link

Document

Return the object associated with the name in the specified scope or null if not found.

Usage

From source file:net.ontopia.topicmaps.db2tm.Utils.java

/**
 * INTERNAL: Helper method for maintaining a relation mapping
 * instance throughout a page context./*  w  w w .  j  a va  2  s.c  o m*/
 */
public static RelationMapping getRelationMapping(PageContext ctxt) {
    RelationMapping db = (RelationMapping) ctxt.getAttribute("RelationMapping", PageContext.APPLICATION_SCOPE);
    if (db == null) {
        db = new RelationMapping();
        ctxt.setAttribute("RelationMapping", db, PageContext.APPLICATION_SCOPE);
    }
    return db;
}

From source file:net.ontopia.topicmaps.nav2.utils.FrameworkUtils.java

/**
 * INTERNAL: Gets user object out of session scope.
 *///  w ww.j  a v a 2 s . com
public static UserIF getUser(PageContext pageContext, boolean create) {
    try {
        Object obj = pageContext.getAttribute(NavigatorApplicationIF.USER_KEY, PageContext.SESSION_SCOPE);
        if (obj != null && obj instanceof UserIF)
            return (UserIF) obj;
        else
            // if no user object exists just create a new one
            return (create ? createUserSession(pageContext) : null);

    } catch (java.lang.IllegalStateException e) {

        // sessions not allowed in page, so get the user from the request scope instead
        Object obj = pageContext.getAttribute(NavigatorApplicationIF.USER_KEY, PageContext.REQUEST_SCOPE);
        if (obj != null && obj instanceof UserIF)
            return (UserIF) obj;
        else
            // if no user object exists just create a new one
            return (create ? createUserSession(pageContext, PageContext.REQUEST_SCOPE) : null);

    }
}

From source file:com.icesoft.faces.webapp.parser.ImplementationUtil.java

/**
 * Returns the component tag stack, including checking in the current
 * request as is the strategy of JSF 1.1_02
 * @param pageContext//from  w w w  .  j  ava 2  s  .c om
 * @return list being the component tag stack
 */
public static List getComponentStack(PageContext pageContext) {
    List list = (List) pageContext.getAttribute(getComponentStackKey(), PageContext.REQUEST_SCOPE);
    if (null == list) {
        list = (List) FacesContext.getCurrentInstance().getExternalContext().getRequestMap()
                .get(getComponentStackKey());
    }
    return list;

}

From source file:net.ontopia.topicmaps.nav2.utils.FrameworkUtils.java

/**
 * INTERNAL: Returns the values retrieved from the given variable
 * names or qnames in the order given.//from w  ww .  ja  v  a 2  s.  c  o  m
 *
 * @param params - variable names or qnames, separated by whitespaces.
 */
private static List getMultipleValuesAsList(String params, PageContext pageContext) throws JspTagException {
    log.debug("getMultipleValuesAsList");
    // find parsecontext
    NavigatorPageIF ctxt = (NavigatorPageIF) pageContext.getAttribute(NavigatorApplicationIF.CONTEXT_KEY,
            PageContext.REQUEST_SCOPE);
    ParseContextIF pctxt = (ParseContextIF) ctxt.getDeclarationContext();

    // get the values
    String[] names = StringUtils.split(params);
    List varlist = new ArrayList(names.length);
    for (int i = 0; i < names.length; i++) {
        Collection values;

        if (names[i].indexOf(':') != -1) {
            // it's a qname
            try {
                values = Collections.singleton(pctxt.getObject(new QName(names[i])));
            } catch (AntlrWrapException e) {
                throw new JspTagException(e.getException().getMessage() + " (in action parameter list)");
            }
        } else
            // it's a variable name
            values = InteractionELSupport.extendedGetValue(names[i], pageContext);

        varlist.add(values);
    }
    return varlist;
}

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

/**
 * wBeanwXR?[v?B/*from   w  w w .  java  2  s. co m*/
 * ?scopeNameNull??PageScope?B
 * 
 * @param pageContext y?[WReLXg
 * @param name Bean
 * @param scopeName BeanXR?[v
 * @return Bean
 * @throws JspException vXR?[v???
 */
public static Object lookup(PageContext pageContext, String name, String scopeName) throws JspException {

    if (scopeName == null) {
        return pageContext.findAttribute(name);
    }

    return pageContext.getAttribute(name, getScope(scopeName));

}

From source file:de.iteratec.iteraplan.presentation.tags.TagUtils.java

/**
 * Locate and return the specified bean, from an optionally specified scope, in the specified page
 * context. If no such bean is found, return <code>null</code> instead.
 * /*from  www. jav a  2 s.c o m*/
 * @param pageContext
 *          Page context to be searched
 * @param name
 *          Name of the bean to be retrieved
 * @param scopeName
 *          Scope to be searched (page, request, session, application) or <code>null</code> to use
 *          <code>findAttribute()</code> instead
 * @return JavaBean in the specified page context
 * @throws JspException
 *           if an invalid scope name is requested
 */
public static Object lookup(PageContext pageContext, String name, String scopeName) throws JspException {

    if (scopeName == null) {
        return pageContext.findAttribute(name);
    }

    return pageContext.getAttribute(name, getScope(scopeName));
}

From source file:com.eurelis.opencms.admin.xmltransformation.ui.CmsXmlMockProcessDialog.java

public static CmsXmlMockProcessDialog newInstance(PageContext context, HttpServletRequest req,
        HttpServletResponse res) {/* www  . j  ava  2s . c  o m*/

    String currentParamSessionSortCol = (String) context.getAttribute("sort_column", PageContext.SESSION_SCOPE);
    CmsListOrderEnum currentSessionSortOrder = (CmsListOrderEnum) context.getAttribute("sort_order",
            PageContext.SESSION_SCOPE);

    String requestParamSessionSortCol = req.getParameter(PARAM_SORT_COL);
    String action = req.getParameter(PARAM_ACTION);

    CmsListOrderEnum listOrder;

    boolean refreshList = false;

    if (currentParamSessionSortCol == null || requestParamSessionSortCol == null) {
        listOrder = CmsListOrderEnum.ORDER_ASCENDING;
        requestParamSessionSortCol = LIST_COLUMN_PATH;
    } else {
        if (action.equals(LIST_SORT)) {

            if (requestParamSessionSortCol.equals(currentParamSessionSortCol)) {
                refreshList = true;
                if (currentSessionSortOrder.equals(CmsListOrderEnum.ORDER_ASCENDING)) {
                    listOrder = CmsListOrderEnum.ORDER_DESCENDING;
                } else {
                    listOrder = CmsListOrderEnum.ORDER_ASCENDING;
                }

            } else {
                listOrder = CmsListOrderEnum.ORDER_ASCENDING;
            }

        } else {
            listOrder = currentSessionSortOrder;
        }

    }

    context.setAttribute("sort_order", listOrder, PageContext.SESSION_SCOPE);
    context.setAttribute("sort_column", requestParamSessionSortCol, PageContext.SESSION_SCOPE);

    CmsXmlMockProcessDialog returnObject = new CmsXmlMockProcessDialog(
            new CmsJspActionElement(context, req, res), LIST_ID,
            Messages.get().container(Messages.GUI_MOCK_PROCESS_LIST_NAME_0), requestParamSessionSortCol,
            listOrder, null);

    if (refreshList) {
        returnObject.refreshList();
    }

    return returnObject;

}

From source file:net.ontopia.topicmaps.webed.impl.utils.TagUtils.java

public static String getRequestId(PageContext pageContext) {
    return (String) pageContext.getAttribute(FormTag.REQUEST_ID_ATTRIBUTE_NAME, PageContext.REQUEST_SCOPE);
}

From source file:net.ontopia.topicmaps.webed.impl.utils.TagUtils.java

/**
 * Gets the name of the action group as an attribute value (residing
 * in the page scope).//from w ww.  ja  v  a 2 s. c o m
 */
public static String getActionGroup(PageContext pageContext) {
    return (String) pageContext.getAttribute(Constants.RA_ACTIONGROUP, PageContext.REQUEST_SCOPE);
}

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

/**
 * Get the bean out of the proper scope.
 *///from  w w  w . j ava2 s . c  om
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);
}