6 Replies Latest reply on Nov 11, 2005 6:29 AM by Jan Arend Jansen

    Stopping and starting long running conversations

    Jan Arend Jansen Newbie

      Imagine a Use Case that would allow a user to enter records (say User objects) one after the other. A record is created using multiple screens. After saving the first 'record' a final readonly screen is presented with a summaru of the submitted fields. The user may than choose 'Ok and create another" action. This would commit the record and start the creation of a new record from the beginning.

      I've tried to model this with a long running conversation in Seam. The problem is that the action that confirms the record and starts the creation of a new record, needs to end the conversation and start a new one.

      It seems impossible to annotate the same action with @Begin and @End, because that would simply start and stop a conversation immediately.

      Is there a way to solve this catch-22?

        • 1. Re: Stopping and starting long running conversations
          Gavin King Master

          You don't need this functionality to implement your usecase. Just end the conversation on the "Ok and create another" action. And start a new conversation when the form is submitted.

          I think you've somehow misunderstood something here....


          P.S.

          The problem is that conversations (of necessity) are created and destroyed at the beginning and end of the actual *request*. We don't destroy conversations in the middle of requests, since that could break all kinds of stuff.

          I suppose you could use a browser redirect. Not sure what is the best way to do this in JSF.

          Alternatively, I guess we *could* provide some way to destory a conversation "early", at the beginning of the RESTORE_VIEW phase, for example...

          • 2. Re: Stopping and starting long running conversations
            Jan Arend Jansen Newbie

            gavin, what i've understood about conversations is that it can span multiple requests, right? So my usecase is containes multiple requests that build the data necessary, and the last request ("Ok and create another") will persist the data. At this point in time I need to start a new conversation for the next 'new user dialog'

            The way I've modelled it is that there is an actionmethod that begins the conversation (annotated with begin and called from a command action). This initialilzes the form (queries some dropdown data on the form). The last request persists and navigates back to the empty form (that needs initialization in a 'new' conversation, i thought).

            I suppose I could just reinitialize the conversation and keep it for the next set of requests (for the next user dialog). That way the conversation would live for as long as the use continues to do 'new user dialogs'. It would end when the user switches to another use case.

            • 3. Re: Stopping and starting long running conversations
              Gavin King Master

               

              "jajansen" wrote:
              At this point in time I need to start a new conversation for the next 'new user dialog'


              Negative. You only need to end the first conv at that point.

              "jajansen" wrote:
              The last request persists and navigates back to the empty form (that needs initialization in a 'new' conversation, i thought).


              Negative. Why on earth would you need the new conversation just to populate the form with blanks?


              • 4. Re: Stopping and starting long running conversations
                Jan Arend Jansen Newbie

                 

                Negative. Why on earth would you need the new conversation just to populate the form with blanks?


                Because the form is not filled with blanks. There is some data in dropdown boxes that needs to be fetched from the database.



                • 5. Re: Stopping and starting long running conversations
                  Gavin King Master

                  Data in dropdown boxes doesn't sound like conversation-scoped state ;-)

                  Try putting it in the request, session, or application scope.

                  • 6. Re: Stopping and starting long running conversations
                    Jan Arend Jansen Newbie

                    Right, good point. I'll try that ;-)