6 Replies Latest reply on Feb 19, 2008 2:55 PM by gavin.king

    Conversation Scoped Observers

    flashguru

      Good day everybody!


      What is the current recommendation for using conversation scoped observers?


      I have a conversation scoped component that listens to the loginSuccessful event, however, the current org.jboss.seam.core.Events.raiseEvent() method does not handle the scenario where there are multiple conversation instances, and instead only looks for the observer at the foreground conversation.


      This problem might become more common once natural conversations are used.  For example, a page that uses a natural conversation might want to display itself differently once the user logs in while the conversation is still active.


      Thanks

        • 1. Re: Conversation Scoped Observers
          flashguru

          The more I think about it the more complex the issue is.


          If a session-scoped component fires an event that has a conversation-scoped observer, should all instances of the observer from all available conversations be notified?


          It sounds like conversation-scope observers better not count on events fired by components from any other scopes but the conversation scope.

          • 2. Re: Conversation Scoped Observers
            flashguru

            As far as I can tell, Seam does not have the concept of scoped events. That is, there is no way for specifying the scope of the event when calling Events.raiseEvent().


            Therefore, I can only think of the following as the guideline when writing conversation-scoped observers:



            Your conversation-scoped observers should only listen to events that you deem to be of conversation scoped nature. The 'loginSuccessful' event is an example of an event that you should avoid listening to in your conversation-scoped components.

            • 3. Re: Conversation Scoped Observers
              gavin.king

              Seam events are always processed in the current contexts.

              • 4. Re: Conversation Scoped Observers
                gavin.king

                P.S. Please use your real name and email address here.

                • 5. Re: Conversation Scoped Observers
                  flashguru

                  Thanks Gavin!


                  I am addicted to conversation-scoped components but in the case of events, they do not seem to really go well as observers :)



                  • 6. Re: Conversation Scoped Observers
                    gavin.king

                    It sounds to me like you should be using a session-scoped observer in this particular case. (You're trying to affect-some session-global state, by the sounds of it.)