### Eclipse Workspace Patch 1.0 #P javaserverfaces-sources Index: jsf-ri/src/com/sun/faces/el/FacesCompositeELResolver.java =================================================================== RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/el/FacesCompositeELResolver.java,v retrieving revision 1.9 diff -u -r1.9 FacesCompositeELResolver.java --- jsf-ri/src/com/sun/faces/el/FacesCompositeELResolver.java 17 Dec 2007 21:46:09 -0000 1.9 +++ jsf-ri/src/com/sun/faces/el/FacesCompositeELResolver.java 31 Jan 2010 16:39:27 -0000 @@ -65,12 +65,13 @@ throws ELException { context.setPropertyResolved(false); - if (FacesContext.getCurrentInstance() == null) { + FacesContext fc = this.getFacesContext(context); + if (fc == null) { return null; } - setChainType(); + setChainType(fc); Object result = super.getValue(context, base, property); - clearChainType(); + clearChainType(fc); return result; } @@ -79,12 +80,13 @@ throws ELException { context.setPropertyResolved(false); - if (FacesContext.getCurrentInstance() == null) { + FacesContext fc = this.getFacesContext(context); + if (fc == null) { return null; } - setChainType(); + setChainType(fc); Class result = super.getType(context, base, property); - clearChainType(); + clearChainType(fc); return result; } @@ -93,32 +95,35 @@ public void setValue(ELContext context, Object base, Object property, Object val) throws ELException { context.setPropertyResolved(false); - if (FacesContext.getCurrentInstance() == null) { + FacesContext fc = this.getFacesContext(context); + if (fc == null) { return; } - setChainType(); + setChainType(fc); super.setValue(context, base, property, val); - clearChainType(); + clearChainType(fc); } public boolean isReadOnly(ELContext context, Object base, Object property) throws ELException { context.setPropertyResolved(false); - if (FacesContext.getCurrentInstance() == null) { + FacesContext fc = this.getFacesContext(context); + if (fc == null) { return false; } - setChainType(); + setChainType(fc); boolean result = super.isReadOnly(context, base, property); - clearChainType(); + clearChainType(fc); return result; } public Iterator getFeatureDescriptors(ELContext context, Object base) { - setChainType(); + FacesContext fc = this.getFacesContext(context); + setChainType(fc); Iterator result = super.getFeatureDescriptors(context, base); - clearChainType(); + clearChainType(fc); return result; } @@ -155,8 +160,8 @@ * the current expression is.

*/ - private void setChainType() { - RequestStateManager.set(FacesContext.getCurrentInstance(), + private void setChainType(FacesContext context) { + RequestStateManager.set(context, RequestStateManager.EL_RESOLVER_CHAIN_TYPE_NAME, chainType); } @@ -166,10 +171,23 @@ * chain the current expression is.

*/ - private void clearChainType() { - RequestStateManager.remove(FacesContext.getCurrentInstance(), + private void clearChainType(FacesContext context) { + RequestStateManager.remove(context, RequestStateManager.EL_RESOLVER_CHAIN_TYPE_NAME); } + + /** + * @param elContext current ELContext + * @return true if the FacesContext is present + */ + private FacesContext getFacesContext(ELContext elContext) { + FacesContext ctx = (FacesContext) elContext.getContext(FacesContext.class); + if (ctx == null) { + ctx = FacesContext.getCurrentInstance(); + } + return ctx; + } + }