5 Replies Latest reply on Mar 5, 2008 6:44 AM by Samuel Doyle

    Using long running conversations just with Seam Remoting?

    Samuel Doyle Apprentice

      Is this possible? If I'm working with an application that has a frontend that is entirely based on AJAX and want to use Seam Remoting. How can I maintain a long running conversation? I remember reading somewhere along the lines that you need to encode a conversationId. How do I get this conversationId initially and how do I make use of it with Seam Remoting if Seam is only used on the backend?


      Thanks, S.D.

        • 1. Re: Using long running conversations just with Seam Remoting?
          Keith Naas Novice

          S.D.,


          When the conversational screen is first displayed, the current conversation id would need to be incorporated into the rendered page. 


          In JSF the documentation describes how to do this. 


          It also talks about how to set and read it within Javascript





          21.5.1. Setting and reading the Conversation ID

          If you intend on using remote calls within the scope of a conversation then you need to be able to read or set the conversation ID in the Seam Remoting Context. To read the conversation ID after making a remote request call Seam.Remoting.getContext().getConversationId(). To set the conversation ID before making a request, call Seam.Remoting.getContext().setConversationId().

          If the conversation ID hasn't been explicitly set with Seam.Remoting.getContext().setConversationId(), then it will be automatically assigned the first valid conversation ID that is returned by any remoting call. If you are working with multiple conversations within your page, then you may need to explicitly set the conversation ID before each call. If you are working with just a single conversation, then you don't need to do anything special.



          Good luck,
          Keith

          • 2. Re: Using long running conversations just with Seam Remoting?
            James Kelly Newbie

            This section covers getting and setting the conversationId. This section implies that if you're only working with a single conversation, you don't need to explicitly set the conversation id:



            If the conversation ID hasn't been explicitly set with Seam.Remoting.getContext().setConversationId(), then it will be automatically assigned the first valid conversation ID that is returned by any remoting call. If you are working with multiple conversations within your page, then you may need to explicitly set the conversation ID before each call. If you are working with just a single conversation, then you don't need to do anything special.


            I assume you can simply annotate your methods with @Begin and @End to manage the long-running conversations.


            • 3. Re: Using long running conversations just with Seam Remoting?
              Samuel Doyle Apprentice

              Thanks,


              This goes back to the post I made a bit back about working with a PHP generated frontend whilst making use of Seam on the backend. I guess in this case the conversationId will need to be stored within the user session manually after making the remoting call on my @Begin method?


              I'm not clear on how the Seam contexts work when not making use of Seam on the frontend.

              • 4. Re: Using long running conversations just with Seam Remoting?
                Shane Bryzak Master

                Before calling a @Begin method, make sure you set the conversation ID to null:


                 Seam.Remoting.getContext().setConversationId(null);



                When the response is returned, you can read the new conversation ID using:


                Seam.Remoting.getContext().getConversationId()



                Using these two methods it is possible to maintain several concurrent conversations at the same time within a single view.  Just make sure you set the conversation ID before you make the remoting call and the call will be made in the scope of that conversational context.

                • 5. Re: Using long running conversations just with Seam Remoting?
                  Samuel Doyle Apprentice

                  Thanks Shane! Good to hear this is possible.


                  S.D.