3 Replies Latest reply on Aug 27, 2007 12:08 PM by jacob.orshalick

    destroying the entire conversation stack through annotation?

      There are situations where I would like to be able to destroy the entire conversation stack if a particular action occurs (say a user cancels everything during a nested conversation). I am currently accomplishing this through the following:

      private void endRootConversation() {
       Conversation conversation = Conversation.instance();
      
       while(conversation.isNested()) {
       conversation.root();
       }
      
       conversation.endBeforeRedirect();
      }
      


      Is is possible to end the root conversation through annotation, or is there potentially a better approach?

      It is of course possible to create my own annotation, say @EndRoot, but this seems like going around the framework. I would prefer to say something like @End(root=true). Maybe I'm just missing something...

      Thanks for any help you may be able to provide.

        • 1. Re: destroying the entire conversation stack through annotat

          By the way, I am currently using Seam 2.0.0.BETA1.

          I have come up with a potential patch that would allow the existing @End annotation to perform this task:

          In org.jboss.seam.annotations.End add the following:

          boolean endRoot() default false;


          and then in the org.jboss.seam.core.ConversationInterceptor.endConversationIfNecessary():

          ...
          boolean endRoot = ( isEndAnnotation && method.getAnnotation(End.class).endRoot() );
          ...
          private void endConversation(boolean beforeRedirect, boolean endRoot)
          {
           Manager manager = Manager.instance();
          
           if(endRoot) {
           if(manager.isNestedConversation()) {
           manager.switchConversation(manager.getRootConversationId());
           }
           }
          
           manager.endConversation(beforeRedirect);
          }
          ...

          and adjust calls to endConversation(boolean beforeRedirect) accordingly.

          This would allow you to specify @End(endRoot=true) on a method so the entire conversation stack is destroyed.

          Any other thoughts? Thanks again for any help.

          • 2. Re: destroying the entire conversation stack through annotat
            pmuir

            You should do this in code as you currently are.

            • 3. Re: destroying the entire conversation stack through annotat

              Okay, no problem. Was just curious if there was annotation based approach, or if this was potentially in the works. Thanks for the response.