6 Replies Latest reply on Sep 5, 2007 10:23 AM by Atle Prange

    Save conversation state in client

    Atle Prange Newbie

      I would like one conversation per open browser window. If the user opens a link in a new tab, i would like the new tab run in a new conversation, and the old tab to continue running in the old conversation.

      I believe that this could be achieved by saving the conversation state in the client, but is this sufficient? I have tried this by setting the appropriate parameter in components.xml on the init component, but it seems to me that the state is still stored on the server side.

      Are there any other ways of achieving the functionality i am after? Could i save some conversation id in the page context and manually assign a conversation to a browser window?

      any suggestions would be appreciated.

        • 1. Re: Save conversation state in client
          Norman Richards Master

          You can specify how the conversation propagates when following a link. Look for the conversationPropagation parameter in the docs.

          • 2. Re: Save conversation state in client
            Atle Prange Newbie

            Thank you for the reply, i realize that my question was unclear at best. What i want is to store the onversation context at the client, so if the user clicks a link the conversation continues, but if the user clicks a link and opens the response in a new window, the new window has "its own" conversation context and the old window still has "its" conversation context stored.

            That way the user can start a new conversation by opening a new window.

            • 3. Re: Save conversation state in client
              stephen.friedrich Novice

              I doubt that there's any chance to detect wether the browser will display a link target in a new tab/window (e.g. middle clicked) or will stay in the same tab (e.g. left clicked).

              I would feel pleased to stand corrected, though. Maybe there's some javascript or other magic that could help.

              • 4. Re: Save conversation state in client
                Atle Prange Newbie

                Yes, the server will not be able to detect if the view is rendered to a new window. But if the conversation context is stored in the client, the server does not need to know.

                If a user opens a view in a new window the context is sendt to the server along with the request, the request is handled, new data is set in the context and the view is rendered to the new browser tab. If the "old" tab sends a different request (for example without opening a new tab), the server handles the "old" context without knowing that it was the same as the previous context. The context data is just set during the application phase, and the response is sendt back to the browser. In effect that means that we have split one conversation in two...

                I thought i could accomplish this with client side conversations (core:init client-side-conversations="true"), but i suspect the conversation id parameter that always is appended somehow makes seam set the different conversation contexts as part of the same conversation (which is of course the expected behavior) Maybe one could turn the conversation id parameter off?

                • 5. Re: Save conversation state in client
                  Atle Prange Newbie

                  How stupid of me. The s:link produces a GET request with parameters, which means that the conversation context cannot posted to the server. If i use normal JSF postback, i can't "open in new tab". I have to think of another solution...

                  • 6. Made it, but...
                    Atle Prange Newbie

                    I managed to make the application behave like i wanted. I replaced all the s:link components with the normal h:commandLink component. But i am pretty sure it's not a very good idea to send the whole state back and forth all the time. The conversation contexts state is a lot larger than i first thought of (of course). All objects my action classes are referencing must be sent back to the browser. If i reduce the state to the minimum, the benefits of actually having a conversation are vanishing.