Author: chris.laprun(a)jboss.com
Date: 2011-09-13 13:03:26 -0400 (Tue, 13 Sep 2011)
New Revision: 7388
Modified:
components/wsrp/branches/clustering/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/JSFBeanContext.java
Log:
- Improved findBean slightly.
Modified:
components/wsrp/branches/clustering/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/JSFBeanContext.java
===================================================================
---
components/wsrp/branches/clustering/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/JSFBeanContext.java 2011-09-13
15:25:10 UTC (rev 7387)
+++
components/wsrp/branches/clustering/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/JSFBeanContext.java 2011-09-13
17:03:26 UTC (rev 7388)
@@ -63,8 +63,25 @@
public <T> T findBean(String name, Class<T> type)
{
final FacesContext facesContext = FacesContext.getCurrentInstance();
- final Object candidate =
facesContext.getApplication().evaluateExpressionGet(facesContext, "#{" + name +
"}", type);
- return checkObject(candidate, type, "Bean named '" + name +
"' is not of type '" + type.getSimpleName() + "'");
+
+ // try to get the bean from the application map first
+ final Map<String, Object> applicationMap =
facesContext.getExternalContext().getApplicationMap();
+ Object candidate = applicationMap.get(name);
+
+ if (candidate == null)
+ {
+ // try to get the bean from an EL expression
+ candidate = facesContext.getApplication().evaluateExpressionGet(facesContext,
"#{" + name + "}", type);
+ }
+
+ if (candidate != null)
+ {
+ return checkObject(candidate, type, "Bean named '" + name +
"' is not of type '" + type.getSimpleName() + "'");
+ }
+ else
+ {
+ return null;
+ }
}
public static Map<String, Object> getSessionMap(FacesContext facesContext)
Show replies by date