private static boolean isInPhase() { return FacesLifecycle.getPhaseId()!=null; }
public static void clearPhaseId() { setPhaseId(null); }
/** * Set up the Seam contexts, except for the conversation * context */ protected void beforeRestoreView(FacesContext facesContext) { FacesLifecycle.beginRequest( facesContext.getExternalContext() ); }
if (facesContext != null) if (FacesLifecycle.getPhaseId() == RESTORE_VIEW ) FacesLifecycle.resumePage(); Map<String, String> parameters = facesContext.getExternalContext().getRequestParameterMap(); ConversationPropagation.instance().restoreConversationId(parameters); pageContext.get().set("org.jboss.seam.jsf.SeamPhaseListener.conversationFound", conversationFound); FacesLifecycle.resumeConversation(facesContext.getExternalContext());
protected void afterResponseComplete(FacesContext facesContext) { //responseComplete() was called by one of the other phases, //so we will never get to the RENDER_RESPONSE phase //Note: we can't call Manager.instance().beforeRedirect() here, //since a redirect is not the only reason for a responseComplete ExternalContext externalContext = facesContext.getExternalContext(); Manager.instance().endRequest( externalContext.getSessionMap() ); FacesLifecycle.endRequest( facesContext.getExternalContext() ); }
FacesLifecycle.beginExceptionRecovery( facesContext.getExternalContext() ); FacesLifecycle.endRequest( facesContext.getExternalContext() ); facesContext.release(); log.debug("done running exception handlers");
public static void beginRequest(ExternalContext externalContext) { log.debug( ">>> Begin JSF request for " + getRequestPath(externalContext) ); Contexts.eventContext.set( new EventContext( externalContext.getRequestMap() ) ); Contexts.applicationContext.set( new ApplicationContext( externalContext.getApplicationMap() ) ); Contexts.sessionContext.set( new SessionContext( externalContext.getSessionMap() ) ); Session session = Session.getInstance(); if ( session!=null && session.isInvalidDueToNewScheme( Pages.instance().getRequestScheme( FacesContext.getCurrentInstance() ) ) ) { invalidateSession(externalContext); } Contexts.conversationContext.set(null); //in case endRequest() was never called //Events.instance(); //TODO: only for now, until we have a way to do EL outside of JSF! saveRequestPath(externalContext); }
public static void endRequest(ExternalContext externalContext) { log.debug("After render response, destroying contexts"); try { Session session = Session.getInstance(); boolean sessionInvalid = session!=null && session.isInvalid(); Contexts.flushAndDestroyContexts(); if (sessionInvalid) { Lifecycle.clearThreadlocals(); clearPhaseId(); invalidateSession(externalContext); //actual session context will be destroyed from the listener } } finally { Lifecycle.clearThreadlocals(); log.debug( "<<< End JSF request for " + getRequestPath(externalContext) ); } }
/** * Restore the page and conversation contexts during a JSF request */ protected void afterRestoreView(FacesContext facesContext) { boolean conversationFound = Contexts.isPageContextActive() ? Contexts.getPageContext().isSet("org.jboss.seam.jsf.SeamPhaseListener.conversationFound") : false; FacesLifecycle.resumePage(); Map parameters = facesContext.getExternalContext().getRequestParameterMap(); if (!conversationFound) // there is exceptional case when restoring of conversation wasn't called while page context was lazily initialized { ConversationPropagation.instance().restoreConversationId(parameters); conversationFound = Manager.instance().restoreConversation(); } FacesLifecycle.resumeConversation( facesContext.getExternalContext() ); postRestorePage(facesContext, parameters, conversationFound); }
FacesLifecycle.beginExceptionRecovery(facesContext.getExternalContext());
FacesLifecycle.clearPhaseId();
FacesLifecycle.endRequest(context.getExternalContext());
@Override protected boolean isFacesContextActive() { return FacesContext.getCurrentInstance() != null && FacesLifecycle.getPhaseId() != null; }
protected void afterRenderResponse(FacesContext facesContext) { //do this both before and after render, since conversations //and pageflows can begin during render FacesManager.instance().prepareBackswitch(facesContext); PersistenceContexts persistenceContexts = PersistenceContexts.instance(); if (persistenceContexts != null) { persistenceContexts.afterRender(); } ExternalContext externalContext = facesContext.getExternalContext(); Manager.instance().endRequest( externalContext.getSessionMap() ); FacesLifecycle.endRequest(externalContext); }
private boolean preRenderPage(FacesContext facesContext) { if ( Pages.isDebugPage() ) { return false; } else { FacesLifecycle.setPhaseId(PhaseId.INVOKE_APPLICATION); boolean actionsWereCalled = false; try { actionsWereCalled = Pages.instance().preRender(facesContext); return actionsWereCalled; } finally { FacesLifecycle.setPhaseId(PhaseId.RENDER_RESPONSE); if (actionsWereCalled) { FacesMessages.afterPhase(); handleTransactionsAfterPageActions(facesContext); //TODO: does it really belong in the finally? } } } }
private static PhaseId getPhaseId() { PhaseId phaseId = FacesLifecycle.getPhaseId(); if (phaseId==null) { throw new IllegalStateException("No phase id bound to current thread (make sure you do not have two SeamPhaseListener instances installed)"); } return phaseId; }
FacesLifecycle.endRequest(externalContext);
public void beforePhase(PhaseEvent event) FacesLifecycle.setPhaseId( event.getPhaseId() ); //since this gets called before SeamPhaseListener!
@Override protected void storeConversationToViewRootIfNecessary() { FacesContext facesContext = FacesContext.getCurrentInstance(); if ( facesContext!=null && (FacesLifecycle.getPhaseId()==PhaseId.RENDER_RESPONSE || FacesLifecycle.getPhaseId()==PhaseId.RESTORE_VIEW) ) { FacesPage.instance().storeConversation(); } }
FacesLifecycle.endRequest( facesContext.getExternalContext() );