List of usage examples for javax.servlet.jsp PageContext getAttributeNamesInScope
abstract public Enumeration<String> getAttributeNamesInScope(int scope);
From source file:eionet.cr.util.Util.java
/** * * @param pageContext//from w w w.ja va 2s.c om * @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:org.qifu.ui.UIComponentValueUtils.java
public static Object getOgnlProcessObjectFromPageContextOrRequest(PageContext pageContext, String expression) { Map<String, Object> ognlRoot = new HashMap<String, Object>(); HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); Enumeration<String> pcNames = pageContext.getAttributeNamesInScope(PageContext.PAGE_SCOPE); Enumeration<String> pNames = request.getParameterNames(); Enumeration<String> aNames = request.getAttributeNames(); /**/*from w w w .j a v a 2 s . c om*/ * ognlRoot , ?: pageContext.getAttribute > request.getParameter > request.getAttribute */ while (pcNames.hasMoreElements()) { String key = pcNames.nextElement(); ognlRoot.put(key, pageContext.getAttribute(key)); } while (pNames.hasMoreElements()) { String key = pNames.nextElement(); if (ognlRoot.get(key) == null) { ognlRoot.put(key, request.getParameter(key)); } } while (aNames.hasMoreElements()) { String key = aNames.nextElement(); if (ognlRoot.get(key) == null) { ognlRoot.put(key, request.getAttribute(key)); } } if (ognlRoot.size() == 0) { ognlRoot = null; return null; } Object val = null; try { val = Ognl.getValue(expression, ognlRoot); } catch (OgnlException e) { //e.printStackTrace(); } ognlRoot.clear(); ognlRoot = null; return val; }