4 Replies Latest reply on Jan 16, 2007 11:32 AM by yoav200

    Conversation problem

    yoav200

      Hello,

      I have a seam application, I want to start a conversation when I enter a page and end it when I leave the page.

      I want the associate EJB to be destroyed when the conversation ends.
      I used the @Begin and @End but it looks like my EJB does not destroyed immediately.

      On a second page I want the same behavior BUT I need to send id parameter to one of the backing EJB members, so I used the pages.xml like in the dvdstore example, my problem is that I use ajax4jsf and every time the page (or part of it) is rerendered the function set in the pages.xml is called and start a new conversation.

      is there a solution for this kind of situation ?

      thank

        • 1. Re: Conversation problem
          vladimir.kovalyuk

          I tried the following scenario:

          Page /object_details.xhtml is designed to show details of my particular object.
          I tuned pages.xml to map request parameters (such as objejctId) to properties of my SFSB backing the page. And my custom page action was marked as @Begin.
          I realized that in spite whether I'm using AJAX (IceFaces in my case) or not, Seam call that action method every time. So at the second attempt, when Seam tries to invoke action that is binded on a button on the page, it invokes @Begin method again and suggest annotating with @Begin(nested=true). That's a problem of Seam design - it provides us with myriads of possibilities, that are not working in combination some times :)

          In my case I succeeded with introducing a fake page that does nothing but accepting parameters and invoking page action. Page action method returns reference to another page. It helped me to omit reentering into new conversation.
          In other words you need to address your conversational page through the fake page, that does all preparation work for you.

          • 2. Re: Conversation problem
            vladimir.kovalyuk

            I forgot to say that there is no any file corresponding to the fake page in pages.xhtml.

            What I don't like in that design that I don't read from pages.xml that Seam will redirect me to the real page after invoking page action. All the implicit logic is a field where bugs are coming from.

            • 3. Re: Conversation problem
              pmuir

              The EJB will be destroyed when the conversation is removed. Marking a method @End doesn't actually end the conversation, but demotes a long-running conversation to a temporary conversation. The temporary conversation will be destroyed at the end of the current (JSF) request.

              As Vladimir says there are many ways to do similar things in Seam. Other options for starting coversations include using (just add s:conversationPropagation type="begin" on the link that takes you to the page - I find this is often the one I use), using a @Create method marked @Begin so that the conversation is begun when the bean (EJB) is created, using @Begin on a factory method to similar effect, using a page action and marking the conversation @Begin(join=true), using pageflows...

              Try to use the examples and the reference manual to guide you through. You could also try the Seam book by Yuan and Heute.

              • 4. Re: Conversation problem
                yoav200

                How can i force destraction of a bean?