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

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

    bernix

      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?


        • 1. Re: @End from
          bernix


          I am using JBoss AS 4.2.0GA and Seam 2.0GA

          • 2. Re: @End from
            bernix

            Does anyone meet such problem?

            • 3. Re: @End from
              pmuir

              Firstly, please don't bump at hourly intervals.

              You seem to have misunderstood how conversations work. They are bound to your browser window, not to backing beans.

              • 4. Re: @End from
                bernix

                Hi Pete,I am sorry for that.

                Thanks for your comment.

                As I knew,the @Begin(join=true) will propagate the conversation context,does it mean the propagated conversation context will be a new context?and different from the previous one?
                and how can I end the propagated conversation context,and resume the previous?

                • 5. Re: @End from
                  christian.douven

                  "Jaoin" means, that the new conversation will become part of the existing. there will be online ONE conversation in your example. It doesn't matter, in which bean you call @End. Otherwise try "nested". If you don't want this, you can start a new conversation without propagating it. Then you will have two independent conversations.

                  • 6. Re: @End from
                    christian.douven

                    This forum needs an edit-function!

                    Jaoin=Join, online=only

                    • 7. Re: @End from
                      bernix

                      Hi Christian,from your information,I change the code and it works!

                      I add the propagation="none" to the <s:link>, and it show me a exception that beanB @In can not find the object @Out from beanA,I suppose that's because they are at different context,means a new conversation context is created for beanB.

                      Then I change the @In and @Out to

                      @Out(scope=ScopeType.SESSION) @In(required=false, scope=ScopeType.SESSION)

                      then everything works fine.

                      Thanks a lot,Christian.

                      Cheers!