ImplicitObjectELResolver extends ELResolver implements ELConstants { @Override public Object getValue(ELContext context,Object base, Object property) throws ELException { if (base != null) { return null; } if (property == null) { String message = MessageUtils.getExceptionMessageString (MessageUtils.NULL_PARAMETERS_ERROR_MESSAGE_ID, "property"); throw new PropertyNotFoundException(message); } Integer index = IMPLICIT_OBJECTS.get(property.toString()); if (index == null) { return null; } else { FacesContext facesContext = (FacesContext) context.getContext(FacesContext.class); ExternalContext extCtx = facesContext.getExternalContext(); switch (index) { case APPLICATION: context.setPropertyResolved(true); return extCtx.getContext(); case APPLICATION_SCOPE: context.setPropertyResolved(true); return extCtx.getApplicationMap(); case COMPOSITE_COMPONENT: context.setPropertyResolved(true); CompositeComponentStackManager manager = CompositeComponentStackManager.getManager(facesContext); Object o = manager.peek(); if (o == null) { o = UIComponent.getCurrentCompositeComponent(facesContext); } return o; case COMPONENT: UIComponent c = UIComponent.getCurrentComponent(facesContext); context.setPropertyResolved(c != null); return c; case COOKIE: context.setPropertyResolved(true); return extCtx.getRequestCookieMap(); case FACES_CONTEXT: context.setPropertyResolved(true); return facesContext; case FLASH: context.setPropertyResolved(true); return facesContext.getExternalContext().getFlash(); case FACES_FLOW: context.setPropertyResolved(true); FlowHandler flowHandler = facesContext.getApplication().getFlowHandler(); Map<Object, Object> flowScope = null; if (null != flowHandler) { flowScope = flowHandler.getCurrentFlowScope(); } return flowScope; case HEADER: context.setPropertyResolved(true); return extCtx.getRequestHeaderMap(); case HEADER_VALUES: context.setPropertyResolved(true); return extCtx.getRequestHeaderValuesMap(); case INIT_PARAM: context.setPropertyResolved(true); return extCtx.getInitParameterMap(); case PARAM: context.setPropertyResolved(true); return extCtx.getRequestParameterMap(); case PARAM_VALUES: context.setPropertyResolved(true); return extCtx.getRequestParameterValuesMap(); case REQUEST: context.setPropertyResolved(true); return extCtx.getRequest(); case REQUEST_SCOPE: context.setPropertyResolved(true); return extCtx.getRequestMap(); case RESOURCE: context.setPropertyResolved(true); return facesContext.getApplication().getResourceHandler(); case SESSION: context.setPropertyResolved(true); return extCtx.getSession(true); case SESSION_SCOPE: context.setPropertyResolved(true); return extCtx.getSessionMap(); case VIEW: context.setPropertyResolved(true); return facesContext.getViewRoot(); case VIEW_SCOPE: UIViewRoot root = facesContext.getViewRoot(); if (root != null) { context.setPropertyResolved(true); return facesContext.getViewRoot().getViewMap(); } default: return null; } } } ImplicitObjectELResolver(); @Override Object getValue(ELContext context,Object base, Object property); @Override void setValue(ELContext context, Object base, Object property,
                          Object val); @Override boolean isReadOnly(ELContext context, Object base, Object property); @Override Class<?> getType(ELContext context, Object base, Object property); @Override Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base); @Override Class<?> getCommonPropertyType(ELContext context, Object base);  }
@Test public void testGetValueForCC() throws Exception { MockFacesContext mockFacesContext = new MockFacesContext( new MockExternalContext( new MockServletContext(), new MockHttpServletRequest(), new MockHttpServletResponse())); mockFacesContext.setApplication(new MockApplication()); new ImplicitObjectELResolver().getValue(mockFacesContext.getELContext(), null, "cc"); assertTrue(mockFacesContext.getELContext().isPropertyResolved()); }