4 Replies Latest reply on Nov 23, 2012 7:21 AM by banzeletti

    HOWTO start a brand-new conversation in JSR-299/WELD?

    banzeletti
      Hello community,

       

      I'm trying to figure out how to solve the following problem:

       

      • My webapp shows a list of persons. There is an "edit" link at each line (one for each person).
      • the user clicks the "edit" link. The webapp shows a form with the selected person's data.

        

      Technically, as long as the user edits this person, a long-running conversation will be tied to this personEditor form. So far, so good.


      • As soon as the user clicks the "edit" link of another person's row, a second personEditor form should pop up somewhere on the web page, having its own long-running conversation.

       

      From what I understood from JSR-299/Weld, this simply cannot be done. Am I right? I am looking for something similar to the good-old-Seam2 conversations which could stack and nest...

       

      Any help highly appreciated.

      Kind regards

      Bernhard

        • 1. Re: HOWTO start a brand-new conversation in JSR-299/WELD?
          luksa

          Well if the edit link does not contain the cid parameter, you should be able to start a new long-running conversation. But if the link contains the cid parameter, the whole request will be tied to the conversation with the requested cid, and you will not be able to start a new conversatoin in that request. A request is always associated with exactly one conversation.

           

          In other words, all you need to do is to make sure the edit link does not have the cid parameter.

          1 of 1 people found this helpful
          • 2. Re: HOWTO start a brand-new conversation in JSR-299/WELD?
            banzeletti

            Dear Marko,

             

            thank you very much for your helpful reply. The remaining question is on how to render a h:commandLink from an already existing long-running transaction WITHOUT the cid (as far as I understood the cid gets inserted automatically as soon as the response is rendered within an already existing long running conversation). Can I somehow influence this behaviour, eg. in the h:form tag? I know it is VERY counter-intuitive to what JSR-299/Weld is supposed to be doing for me, because it keeps all related stuff synched with the same conversation id... only that I wand JSF to render a response with a JSF link that is NOT part of the current long-running conversation.

             

            In terms of the example above: There are two areas in the browser window, a "left tree" with the search result and edit person links and a "work area" with one "tab" for each person "in editing".  When I click the "edit" link in the left tree, the whole browser-window re-rendereds (w/o AJAX) and thus the cid of the most recently opened partner editor becomes part of each "edit" link. So whenever I click another "edit" link (for another partner), it already has a conversation id assigned to it - the one of the first edited partner. This not only breaks my intention, it also results in  an exception similar to "cannot promote a conversation that already is long-running".

             

            Kind regards,

            Bernhard

            • 3. Re: HOWTO start a brand-new conversation in JSR-299/WELD?
              luksa

              Do you really need a commandLink? If you create your edit link with <h:link>, the cid will not be in the href of the link. The cid is automatically propagated only with <h:commandLink> and such.

               

              Take a look at http://www.andygibson.net/blog/tutorial/cdi-conversations-part-2/ (the bottom section: Workspace management). I think this is exactly what you are looking for.  In your case, each tab is a separate workspace, so each tab will have a <h:link ...><f:param name="cid"...></h:link> in the tab itself. For links in the left tree, simply use <h:link> without <f:param>.

              • 4. Re: HOWTO start a brand-new conversation in JSR-299/WELD?
                banzeletti

                Thanks Marko, this was exactly what I was looking for.