7 Replies Latest reply on Dec 21, 2007 5:22 AM by Bernix Ning

    @End from "join" ends all conversations - unexpected action

    Bernix Ning Newbie

      I have two beans in conversation scope, beanA and beanB. beanA is backing pageA individually,and beanB is backing pageB individually.
      beanA will begin the long-running conversation in pageA at first, then we jump to pageB, pageB will begin(join=true) beanB.
      but when we end the joined conversation in beanB.done , the beanA is destroyed as well.....

      beanA

      @Stateful
      @Scope(CONVERSATION)
      @Name("beanA")
      public class BeanA implements IBeanA {
      
       public BeanA() {
       System.out.println(">>>>>> BeanA is constructed.");
       }
      
       @Begin
       public void init() {
       System.out.println(">>>>>> BeanA is initialized.");
       }
      
       @End
       public void done() {
       System.out.println(">>>>>> BeanA is done.");
       }
      
       @Remove
       public void destroy() {
       System.out.println(">>>>>> BeanA is destroyed.");
       }
      }



      beanB
      @Stateful
      @Name("beanB")
      @Scope (CONVERSATION)
      public class BeanB implements IBeanB {
      
       public BeanB() {
       System.out.println(">>>>>> BeanB is constructed.");
       }
      
       @Begin(join=true)
       public void init() {
       System.out.println(">>>>>> BeanB is initialized.");
       }
      
       @End(beforeRedirect=true)
       public void done() {
       System.out.println(">>>>>> BeanB is done.");
       }
      
       @Remove
       public void destroy() {
       System.out.println(">>>>>> BeanB is destroyed.");
       }
      }



      home.xhtml
      <s:link view="/pageA.xhtml" action="#{beanA.init()}" value="Go to beanA">



      pageA
      <s:link view="/pageB.xhtml" action="#{beanB.init()}" value="Go to beanB"/>



      pageB
      <h:form>
       <h:commandButton action="#{beanB.done}" value="Done beanB"/>
      </h:form>



      pageB.page.xml
      <navigation from-action="#{beanB.done}">
       <redirect view-id="/pageA.xhtml"/>
       </navigation>



      we do the following steps:
      1. enter home page
      2. link to pageA
      3. link to pageB
      4. click "Done beanB" in pageB

      then we got the exception.....the log is:
      16:31:46,333 INFO [STDOUT] >>>>>> BeanA is constructed.
      16:31:46,458 INFO [STDOUT] >>>>>> BeanA is initialized.
      16:31:49,458 INFO [STDOUT] >>>>>> BeanB is constructed.
      16:31:49,489 INFO [STDOUT] >>>>>> BeanB is initialized.
      16:31:56,129 INFO [STDOUT] >>>>>> BeanB is done.
      16:31:56,145 INFO [STDOUT] >>>>>> BeanB is destroyed.
      16:31:56,161 INFO [STDOUT] >>>>>> BeanA is destroyed.
      16:31:56,254 INFO [STDOUT] >>>>>> BeanA is constructed.
      


      Why the @End in beanB.done() cause the beanA to be destroyed?
      We would hope that resume to beanA when beanB is done.

      I know we can use nested conversation in beanB,yes,nested conversation works OK.
      I just wondering,if I join a conversation,how can I end it then resume to the previous long-running conversation?