[jboss-cvs] jboss-seam/src/main/org/jboss/seam/jsf ...

Gavin King gavin.king at jboss.com
Fri Nov 3 17:47:24 EST 2006


  User: gavin   
  Date: 06/11/03 17:47:24

  Modified:    src/main/org/jboss/seam/jsf    
                        AbstractSeamPhaseListener.java
                        SeamPhaseListener.java
                        SeamPortletPhaseListener.java SeamStateManager.java
  Log:
  decoupled the endRequest() processing in Manager from storing stuff in the ViewRoot
  
  Revision  Changes    Path
  1.20      +23 -26    jboss-seam/src/main/org/jboss/seam/jsf/AbstractSeamPhaseListener.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: AbstractSeamPhaseListener.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/jsf/AbstractSeamPhaseListener.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -b -r1.19 -r1.20
  --- AbstractSeamPhaseListener.java	31 Oct 2006 22:29:41 -0000	1.19
  +++ AbstractSeamPhaseListener.java	3 Nov 2006 22:47:24 -0000	1.20
  @@ -5,6 +5,7 @@
   import java.util.Map;
   
   import javax.faces.application.FacesMessage;
  +import javax.faces.context.ExternalContext;
   import javax.faces.context.FacesContext;
   import javax.faces.event.PhaseEvent;
   import javax.faces.event.PhaseId;
  @@ -41,7 +42,7 @@
      /**
       * Restore the page and conversation contexts during a JSF request
       */
  -   public static void restoreAnyConversationContext(FacesContext facesContext)
  +   public void afterRestoreView(FacesContext facesContext)
      {
         Lifecycle.resumePage();
         Map parameters = facesContext.getExternalContext().getRequestParameterMap();
  @@ -64,29 +65,12 @@
      }
      
      /**
  -    * Store the page and conversation contexts during a JSF request
  -    */
  -   public static void storeAnyConversationContext(FacesContext facesContext)
  -   {      
  -      if ( !Contexts.isConversationContextActive() )
  -      {
  -         log.debug( "No active conversation context" );
  -      }
  -      else
  -      {
  -         Lifecycle.flushClientConversation();
  -         ContextAdaptor session = ContextAdaptor.getSession( facesContext.getExternalContext(), true );
  -         Manager.instance().storeConversation( session, facesContext.getExternalContext().getResponse() );
  -      }
  -   }
  -   
  -   /**
       * Look for a DataModel row selection in the request parameters,
       * and apply it to the DataModel.
       * 
       * @param parameters the request parameters
       */
  -   private static void selectDataModelRow(Map parameters)
  +   private void selectDataModelRow(Map parameters)
      {
         String dataModelSelection = (String) parameters.get("dataModelSelection");
         if (dataModelSelection!=null)
  @@ -141,11 +125,11 @@
            Pages.instance().applyRequestParameterValues(facesContext);
         }
         
  -      Lifecycle.flushPage();
         if ( Contexts.isPageContextActive() )
         {
  -         //force refresh of the conversation lists (they are kept in PAGE context)
            Context pageContext = Contexts.getPageContext();
  +         pageContext.flush();
  +         //force refresh of the conversation lists (they are kept in PAGE context)
            pageContext.remove( Seam.getComponentName(ConversationList.class) );
            pageContext.remove( Seam.getComponentName(Switcher.class) );
            pageContext.remove( Seam.getComponentName(ConversationStack.class) );
  @@ -157,11 +141,6 @@
         
         if ( facesContext.getResponseComplete() )
         {
  -         //if the page actions called responseComplete(),
  -         //we need to call beforeSaveState(), since the
  -         //component tree will not get rendered
  -         storeAnyConversationContext(facesContext);
  -         
            //workaround for a bug in MyFaces prior to 1.1.3
            if ( Init.instance().isMyFacesLifecycleBug() ) 
            {
  @@ -176,6 +155,24 @@
         
      }
      
  +   protected void afterRender(FacesContext facesContext)
  +   {
  +      ExternalContext externalContext = facesContext.getExternalContext();
  +      Manager.instance().endRequest( ContextAdaptor.getSession(externalContext, true) );
  +      Lifecycle.endRequest(externalContext);
  +   }
  +
  +   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( ContextAdaptor.getSession(externalContext, true) );
  +      Lifecycle.endRequest( facesContext.getExternalContext() );
  +   }
  +
      private boolean callPageActions(PhaseEvent event)
      {
         Lifecycle.setPhaseId( PhaseId.INVOKE_APPLICATION );
  
  
  
  1.92      +3 -25     jboss-seam/src/main/org/jboss/seam/jsf/SeamPhaseListener.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: SeamPhaseListener.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/jsf/SeamPhaseListener.java,v
  retrieving revision 1.91
  retrieving revision 1.92
  diff -u -b -r1.91 -r1.92
  --- SeamPhaseListener.java	16 Oct 2006 15:46:43 -0000	1.91
  +++ SeamPhaseListener.java	3 Nov 2006 22:47:24 -0000	1.92
  @@ -18,8 +18,6 @@
   import org.apache.commons.logging.LogFactory;
   import org.jboss.seam.contexts.Lifecycle;
   import org.jboss.seam.core.FacesMessages;
  -import org.jboss.seam.core.Init;
  -import org.jboss.seam.core.Manager;
   
   /**
    * Manages the Seam contexts associated with a JSF request.
  @@ -66,7 +64,7 @@
         
         if ( event.getPhaseId() == RESTORE_VIEW )
         {
  -         restoreAnyConversationContext(facesContext);
  +         afterRestoreView(facesContext);
         }      
         else if ( event.getPhaseId() == INVOKE_APPLICATION )
         {
  @@ -82,31 +80,11 @@
               
         if ( event.getPhaseId() == RENDER_RESPONSE )
         {
  -         if ( !Manager.instance().isConversationAlreadyStored() ) 
  -         {
  -            //for JSF pages with no form, storeAnyConversationContext()
  -            //will not get called from SeamStateManager.saveSerializedView()
  -            storeAnyConversationContext(facesContext);
  -         }
  -         
  -         if ( !Init.instance().isClientSideConversations() ) 
  -         {
  -            // difficult question: is it really safe to do this here?
  -            // right now we do have to do it after committing the Seam
  -            // transaction because we can't close EMs inside a txn
  -            // (this might be a bug in HEM)
  -            Manager.instance().conversationTimeout( facesContext.getExternalContext() );
  -         }
  -         Lifecycle.endRequest( facesContext.getExternalContext() );
  +         afterRender(facesContext);
         }
         else if ( facesContext.getResponseComplete() )
         {
  -         //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
  -         storeAnyConversationContext(facesContext);
  -         Lifecycle.endRequest( facesContext.getExternalContext() );
  +         afterResponseComplete(facesContext);
         }
         
         Lifecycle.setPhaseId(null);
  
  
  
  1.13      +4 -5      jboss-seam/src/main/org/jboss/seam/jsf/SeamPortletPhaseListener.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: SeamPortletPhaseListener.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/jsf/SeamPortletPhaseListener.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -b -r1.12 -r1.13
  --- SeamPortletPhaseListener.java	8 Oct 2006 14:01:54 -0000	1.12
  +++ SeamPortletPhaseListener.java	3 Nov 2006 22:47:24 -0000	1.13
  @@ -52,7 +52,7 @@
         
         if ( event.getPhaseId() == RENDER_RESPONSE )
         {
  -         restoreAnyConversationContext( facesContext );         
  +         afterRestoreView( facesContext );         
            beforeRender(event);
         }
         else if ( event.getPhaseId()== APPLY_REQUEST_VALUES )
  @@ -70,7 +70,7 @@
         
         if ( event.getPhaseId() == RESTORE_VIEW )
         {
  -         restoreAnyConversationContext(facesContext);
  +         afterRestoreView(facesContext);
         }
         else if ( event.getPhaseId() == INVOKE_APPLICATION )
         {
  @@ -84,13 +84,12 @@
               
         if ( event.getPhaseId() == RENDER_RESPONSE )
         {
  -         Lifecycle.endRequest( facesContext.getExternalContext() );
  +         afterRender(facesContext);
         }
         else if ( event.getPhaseId() == INVOKE_APPLICATION || facesContext.getResponseComplete() )
         {
            Manager.instance().beforeRedirect();
  -         storeAnyConversationContext(facesContext);
  -         Lifecycle.endRequest( facesContext.getExternalContext() );
  +         afterResponseComplete(facesContext);
         }
   
         Lifecycle.setPhaseId(null);
  
  
  
  1.7       +38 -2     jboss-seam/src/main/org/jboss/seam/jsf/SeamStateManager.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: SeamStateManager.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/jsf/SeamStateManager.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -b -r1.6 -r1.7
  --- SeamStateManager.java	25 Oct 2006 15:14:36 -0000	1.6
  +++ SeamStateManager.java	3 Nov 2006 22:47:24 -0000	1.7
  @@ -6,6 +6,11 @@
   import javax.faces.component.UIViewRoot;
   import javax.faces.context.FacesContext;
   
  +import org.jboss.seam.Seam;
  +import org.jboss.seam.contexts.ContextAdaptor;
  +import org.jboss.seam.contexts.Contexts;
  +import org.jboss.seam.core.Init;
  +import org.jboss.seam.core.Manager;
   import org.jboss.seam.core.Pages;
   
   /**
  @@ -50,8 +55,39 @@
   
      @Override
      public SerializedView saveSerializedView(FacesContext facesContext) {
  +      
  +      if ( Contexts.isPageContextActive() )
  +      {
  +         //store the page parameters in the view root
  +         if ( Contexts.isApplicationContextActive() )
  +         {
         Pages.instance().storePageParameters(facesContext);
  -      AbstractSeamPhaseListener.storeAnyConversationContext(facesContext);
  +         }
  +
  +         //store the conversation id and information about
  +         //the pageflow execution state in the view root
  +         if ( Contexts.isEventContextActive() )
  +         {
  +            Manager.instance().writeValuesToViewRoot( 
  +                  ContextAdaptor.getSession( facesContext.getExternalContext(), true ), 
  +                  facesContext.getExternalContext().getResponse() 
  +               );
  +         }
  +
  +         //if we are using client-side conversations, flush
  +         //the conversation context variables to the view root
  +         boolean flushNeeded = Contexts.isApplicationContextActive() &&
  +               Init.instance().isClientSideConversations() &&
  +               Contexts.isConversationContextActive() &&
  +               !Seam.isSessionInvalid();
  +            
  +         if (flushNeeded)
  +         {
  +            Contexts.getConversationContext().flush();
  +         }
  +         
  +      }
  +
         return stateManager.saveSerializedView(facesContext);
      }
   
  
  
  



More information about the jboss-cvs-commits mailing list