public static Object makeExpressionPayload ( String expr ) throws IllegalArgumentException, IllegalAccessException, Exception { FacesContextImpl fc = new FacesContextImpl((ServletContext) null, (ServletRequest) null, (ServletResponse) null); ELContext elContext = new FacesELContext(new CompositeELResolver(), fc); Reflections.getField(FacesContextImplBase.class, "_elContext").set(fc, elContext); ExpressionFactory expressionFactory = ExpressionFactory.newInstance(); ValueExpression ve1 = expressionFactory.createValueExpression(elContext, expr, Object.class); ValueExpressionMethodExpression e = new ValueExpressionMethodExpression(ve1); ValueExpression ve2 = expressionFactory.createValueExpression(elContext, "${true}", Object.class); ValueExpressionMethodExpression e2 = new ValueExpressionMethodExpression(ve2); return Gadgets.makeMap(e2, e); }
@Override public final void renderResponse() { assertNotReleased(); _renderResponse = true; }
@Override public boolean isPostback() { assertNotReleased(); RenderKit renderKit = getRenderKit(); if (renderKit == null) { // NullPointerException with StateManager, because // to restore state it first restore structure, // then fill it and in the middle of the two previous // process there is many calls from _ComponentChildrenList.childAdded // to facesContext.isPostback, and getViewRoot is null. // // Setting a "phantom" UIViewRoot calling facesContext.setViewRoot(viewRoot) // to avoid it is bad, because this is work of RestoreViewExecutor, // and theorically ViewHandler.restoreView must return an UIViewRoot // instance. // // The problem with this is if the user changes the renderkit directly // using f:view renderKitId param, the ResponseStateManager returned // will be the one tied to faces-config selected RenderKit. But the usual // method to check if a request is a postback, is always detect the param // javax.faces.ViewState, so there is no problem after all. String renderKitId = this.getApplication().getViewHandler().calculateRenderKitId(this); RenderKitFactory factory = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY); renderKit = factory.getRenderKit(this, renderKitId); } return renderKit.getResponseStateManager().isPostback(this); }
@Override public boolean isPostback() assertNotReleased(); RenderKit renderKit = getRenderKit(); FacesContext facesContext = getCurrentFacesContext(); if (renderKit == null)
facesContext = new SerializableServletFacesContextImpl(portletContext, request, response); request.getPortletSession().setAttribute(CURRENT_FACES_CONTEXT, facesContext); facesContext.setExternalContext(makeExternalContext(request, response)); setPortletRequestFlag(request); lifecycle.execute(facesContext); if (!facesContext.getResponseComplete()) { response.setRenderParameter(VIEW_ID, facesContext.getViewRoot().getViewId());
@Override public PartialViewContext getPartialViewContext() { assertNotReleased(); if (_partialViewContext == null) { //Get through factory finder if (_partialViewContextFactory == null) { _partialViewContextFactory = (PartialViewContextFactory) FactoryFinder.getFactory(FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY); } // Put actual facesContext as param, not this - this can be wrapped _partialViewContext = _partialViewContextFactory.getPartialViewContext(getCurrentFacesContext()); } return _partialViewContext; }
@Override public final void release() { assertNotReleased(); if (ExternalSpecifications.isCDIAvailable(getExternalContext())) { FacesScopeProvider.destroyBeans(this); } _messages = null; _orderedMessages = null; _currentPhaseId = null; _responseStream = null; _responseWriter = null; _maximumSeverity = null; _partialViewContext = null; _renderKitFactory = null; _partialViewContextFactory = null; if (_facesContextFactory != null) { _facesContextFactory.release(); _facesContextFactory = null; } // release FacesContextImplBase (sets current instance to null) super.release(); }
if (facesContext.getResponseComplete()) return; facesContext.setExternalContext(makeExternalContext(request, response)); lifecycle.render(facesContext);
public ELContext getELContext() { if (_elContext != null) return _elContext; _elContext = new FacesELContext(getApplication().getELResolver(), this); ELContextEvent event = new ELContextEvent(_elContext); for (ELContextListener listener : getApplication().getELContextListeners()) { listener.contextCreated(event); } return _elContext; }
public RenderKit getRenderKit() { if (getViewRoot() == null) { return null; } String renderKitId = getViewRoot().getRenderKitId(); if (renderKitId == null) { return null; } return _renderKitFactory.getRenderKit(this, renderKitId); }
@Override public boolean isPostback() { assertNotReleased(); RenderKit renderKit = getRenderKit(); if (renderKit == null) { // NullPointerException with StateManager, because // to restore state it first restore structure, // then fill it and in the middle of the two previous // process there is many calls from _ComponentChildrenList.childAdded // to facesContext.isPostback, and getViewRoot is null. // // Setting a "phantom" UIViewRoot calling facesContext.setViewRoot(viewRoot) // to avoid it is bad, because this is work of RestoreViewExecutor, // and theorically ViewHandler.restoreView must return an UIViewRoot // instance. // // The problem with this is if the user changes the renderkit directly // using f:view renderKitId param, the ResponseStateManager returned // will be the one tied to faces-config selected RenderKit. But the usual // method to check if a request is a postback, is always detect the param // javax.faces.ViewState, so there is no problem after all. String renderKitId = this.getApplication().getViewHandler().calculateRenderKitId(this); RenderKitFactory factory = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY); renderKit = factory.getRenderKit(this, renderKitId); } return renderKit.getResponseStateManager().isPostback(this); }
@Override public final FacesMessage.Severity getMaximumSeverity() { assertNotReleased(); return _maximumSeverity; }
return new FacesContextImpl((ServletContext)context, (ServletRequest)request, (ServletResponse)response); return new FacesContextImpl((PortletContext)context, (PortletRequest)request, (PortletResponse)response);
@Override public void setCurrentPhaseId(PhaseId currentPhaseId) { assertNotReleased(); _currentPhaseId = currentPhaseId; }
if (externalContext instanceof ReleaseableExternalContext) facesContext = new FacesContextImpl(externalContext, (ReleaseableExternalContext) externalContext, this); facesContext = new FacesContextImpl(externalContext, (ReleaseableExternalContext) defaultExternalContext, this); facesContext = new FacesContextImpl(externalContext, null, this);
@Override public final ResponseStream getResponseStream() { assertNotReleased(); return _responseStream; }
if (externalContext instanceof ReleaseableExternalContext) facesContext = new FacesContextImpl(externalContext, (ReleaseableExternalContext) externalContext, this); facesContext = new FacesContextImpl(externalContext, (ReleaseableExternalContext) defaultExternalContext, this); facesContext = new FacesContextImpl(externalContext, null, this);
@Override public final ResponseWriter getResponseWriter() { assertNotReleased(); return _responseWriter; }
if (externalContext instanceof ReleaseableExternalContext) facesContext = new FacesContextImpl(externalContext, (ReleaseableExternalContext) externalContext, this, _applicationFactory, _renderKitFactory, _partialViewContextFactory); facesContext = new FacesContextImpl(externalContext, (ReleaseableExternalContext) defaultExternalContext, this, _applicationFactory, _renderKitFactory, facesContext = new FacesContextImpl(externalContext, null, this, _applicationFactory, _renderKitFactory, _partialViewContextFactory);
@Override public final boolean getRenderResponse() { assertNotReleased(); return _renderResponse; }