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

Gavin King gavin.king at jboss.com
Fri Nov 3 20:00:14 EST 2006


  User: gavin   
  Date: 06/11/03 20:00:14

  Modified:    src/main/org/jboss/seam/core    FacesPage.java Manager.java
                        Pageflow.java
  Log:
  JBSEAM-460, reduce reliance on StateManager
  
  Revision  Changes    Path
  1.2       +41 -14    jboss-seam/src/main/org/jboss/seam/core/FacesPage.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: FacesPage.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/FacesPage.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- FacesPage.java	27 Oct 2006 12:58:09 -0000	1.1
  +++ FacesPage.java	4 Nov 2006 01:00:14 -0000	1.2
  @@ -5,6 +5,7 @@
   import org.jboss.seam.Component;
   import org.jboss.seam.InterceptionType;
   import org.jboss.seam.ScopeType;
  +import org.jboss.seam.Seam;
   import org.jboss.seam.annotations.Intercept;
   import org.jboss.seam.annotations.Name;
   import org.jboss.seam.annotations.Scope;
  @@ -49,20 +50,14 @@
         conversationIsLongRunning = true;
      }
      
  -   public void storeConversation()
  -   {
  -      Manager manager = Manager.instance();
  -      if ( manager.isReallyLongRunningConversation() )
  +   public void storeConversation(String conversationId)
         {
  -         conversationId = manager.getCurrentConversationId();
  +      this.conversationId = conversationId;
            conversationIsLongRunning = true;
         }
  -      else
  -      {
  -         conversationId = null;
  -         conversationIsLongRunning = false;
  -      }
         
  +   public void storePageflow()
  +   {
         if ( Init.instance().isJbpmInstalled() )
         {
            Pageflow pageflow = Pageflow.instance();
  @@ -110,6 +105,38 @@
         return pageflowNodeName;
      }
   
  +   public void storeConversation()
  +   {
  +      Manager manager = Manager.instance();
  +      
  +      //we only need to execute this code when we are in the 
  +      //RENDER_RESPONSE phase, ie. not before redirects
  +   
  +      boolean sessionValid = !Seam.isSessionInvalid();
  +      if ( sessionValid && manager.isLongRunningConversation() )
  +      {
  +         storeConversation( manager.getCurrentConversationId() );
  +      }
  +      else if ( sessionValid && manager.isNestedConversation() )
  +      {
  +         discardNestedConversation( manager.getParentConversationId() );
  +      }
  +      else
  +      {
  +         discardTemporaryConversation();
  +      }
  +
  +      if ( sessionValid && Init.instance().isClientSideConversations()  )
  +      {
  +         // if we are using client-side conversations, put the
  +         // map containing the conversation context variables 
  +         // into the view root (or remove it for a temp 
  +         // conversation context)
  +         Contexts.getConversationContext().flush();
  +      }
  +
  +   }
  +
      /*public Map<String, Object> getPageParameters()
      {
         return pageParameters==null ? Collections.EMPTY_MAP : pageParameters;
  
  
  
  1.112     +27 -41    jboss-seam/src/main/org/jboss/seam/core/Manager.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Manager.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Manager.java,v
  retrieving revision 1.111
  retrieving revision 1.112
  diff -u -b -r1.111 -r1.112
  --- Manager.java	3 Nov 2006 23:38:27 -0000	1.111
  +++ Manager.java	4 Nov 2006 01:00:14 -0000	1.112
  @@ -19,7 +19,7 @@
   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;
   import javax.portlet.ActionResponse;
   import javax.servlet.http.HttpServletResponse;
   
  @@ -33,6 +33,7 @@
   import org.jboss.seam.annotations.Scope;
   import org.jboss.seam.contexts.ContextAdaptor;
   import org.jboss.seam.contexts.Contexts;
  +import org.jboss.seam.contexts.Lifecycle;
   import org.jboss.seam.contexts.ServerConversationContext;
   import org.jboss.seam.util.Id;
   
  @@ -41,7 +42,7 @@
    *
    * @author Gavin King
    * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
  - * @version $Revision: 1.111 $
  + * @version $Revision: 1.112 $
    */
   @Scope(ScopeType.EVENT)
   @Name("org.jboss.seam.core.manager")
  @@ -338,34 +339,6 @@
         }
      }
      
  -   /**
  -    * Write the conversation id and pageflow info to the response
  -    * if we have a long running conversation.
  -    */
  -   public void writeValuesToViewRoot(ContextAdaptor session, Object response)
  -   {
  -      //we only need to execute this code when we are in the 
  -      //RENDER_RESPONSE phase, ie. not before redirects
  -      if ( isLongRunningConversation() )
  -      {
  -         if ( !Seam.isSessionInvalid() ) 
  -         {
  -            //if the session is invalid, don't put the conversation id
  -            //in the view, 'cos we are expecting the conversation to
  -            //be destroyed by the servlet session listener
  -            org.jboss.seam.core.FacesPage.instance().storeConversation();
  -         }
  -      }
  -      else if ( isNestedConversation() )
  -      {
  -         org.jboss.seam.core.FacesPage.instance().discardNestedConversation( getParentConversationId() );
  -      }
  -      else
  -      {
  -         org.jboss.seam.core.FacesPage.instance().discardTemporaryConversation();
  -      }
  -   }
  -   
      public void unlockConversation()
      {
         ConversationEntry ce = getCurrentConversationEntry();
  @@ -649,21 +622,11 @@
         setLongRunningConversation(true);
         createConversationEntry().setInitiatorComponentName(initiator);
         Conversation.instance(); //force instantiation of the Conversation in the outer (non-nested) conversation
  +      storeConversationToViewRootIfNecessary();
         if ( Events.exists() ) Events.instance().raiseEvent("org.jboss.seam.beginConversation");
      }
   
      /**
  -    * Make a long-running conversation temporary.
  -    */
  -   public void endConversation(boolean beforeRedirect)
  -   {
  -      if ( Events.exists() ) Events.instance().raiseEvent("org.jboss.seam.endConversation");
  -      setLongRunningConversation(false);
  -      destroyBeforeRedirect = beforeRedirect;
  -      endNestedConversations( getCurrentConversationId() );
  -   }
  -   
  -   /**
       * Begin a new nested conversation.
       * 
       * @param ownerName the name of the component starting the conversation
  @@ -676,6 +639,29 @@
         createCurrentConversationIdStack(id).addAll(oldStack);
         ConversationEntry conversationEntry = createConversationEntry();
         conversationEntry.setInitiatorComponentName(ownerName);
  +      storeConversationToViewRootIfNecessary();
  +      if ( Events.exists() ) Events.instance().raiseEvent("org.jboss.seam.beginConversation");
  +   }
  +   
  +   /**
  +    * Make a long-running conversation temporary.
  +    */
  +   public void endConversation(boolean beforeRedirect)
  +   {
  +      if ( Events.exists() ) Events.instance().raiseEvent("org.jboss.seam.endConversation");
  +      setLongRunningConversation(false);
  +      destroyBeforeRedirect = beforeRedirect;
  +      endNestedConversations( getCurrentConversationId() );
  +      storeConversationToViewRootIfNecessary();
  +   }
  +   
  +   private void storeConversationToViewRootIfNecessary()
  +   {
  +      FacesContext facesContext = FacesContext.getCurrentInstance();
  +      if ( facesContext!=null && Lifecycle.getPhaseId()==PhaseId.RENDER_RESPONSE )
  +      {
  +         FacesPage.instance().storeConversation();
  +      }
      }
      
      // two reasons for this: 
  
  
  
  1.38      +14 -0     jboss-seam/src/main/org/jboss/seam/core/Pageflow.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Pageflow.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Pageflow.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -b -r1.37 -r1.38
  --- Pageflow.java	27 Oct 2006 12:58:09 -0000	1.37
  +++ Pageflow.java	4 Nov 2006 01:00:14 -0000	1.38
  @@ -7,6 +7,7 @@
   import javax.faces.application.FacesMessage;
   import javax.faces.component.UIViewRoot;
   import javax.faces.context.FacesContext;
  +import javax.faces.event.PhaseId;
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  @@ -16,6 +17,7 @@
   import org.jboss.seam.annotations.Name;
   import org.jboss.seam.annotations.Scope;
   import org.jboss.seam.contexts.Contexts;
  +import org.jboss.seam.contexts.Lifecycle;
   import org.jboss.seam.pageflow.Page;
   import org.jboss.seam.pageflow.PageflowHelper;
   import org.jbpm.graph.def.Node;
  @@ -241,6 +243,18 @@
         setDirty();
         
         Events.instance().raiseEvent("org.jboss.seam.beginPageflow." + pageflowDefinitionName);
  +      
  +      storePageflowToViewRootIfNecessary();
  +
  +   }
  +
  +   private void storePageflowToViewRootIfNecessary()
  +   {
  +      FacesContext facesContext = FacesContext.getCurrentInstance();
  +      if ( facesContext!=null && Lifecycle.getPhaseId()==PhaseId.RENDER_RESPONSE )
  +      {
  +         FacesPage.instance().storePageflow();
  +      }
      }
      
      public String getNoConversationViewId(String pageflowName, String pageflowNodeName)
  
  
  



More information about the jboss-cvs-commits mailing list