2 Replies Latest reply on Apr 19, 2008 5:24 PM by andygibson.contact.andygibson.net

    Determining Which Conversation You're In

    darthmaul

      Please consider the following use cases:



      1. Widget Search: User searches for a widget merely out of curiosity by visiting a search form, entering search parameters, and navigating from the result set to the detail page for the particular widget selected from the result set.

      2. Widget Order: User searches for a customer, finds him, and then presses a Place Order button.  This takes the user to the Widget Search use case described above.  Except...the search results table will now have an extra column with an Add to Cart button, and navigating to a widget's detail page will feature an Add to Cart button as well.



      As you can see, the Widget Search use case is contained in the Widget Order use case, but I need to know if the user arrives at Widget Search just for kicks or as part of the order process so I can place the Add to Cart buttons accordingly.


      Right now I have the basic Widget Search working perfectly through a joined conversation, and I am considering using JBPM for the order process.


      How would you suggest that I architect things so that I can be aware of which kind conversation I am in (general search or search as part of an order)?


      Thanks for any insight.

        • 1. Re: Determining Which Conversation You're In
          schlegel

          Hi


          Look at the reference manual


          Components for controlling conversations....


          org.jboss.seam.core.conversation.getId()

          • 2. Re: Determining Which Conversation You're In
            andygibson.contact.andygibson.net

            Yes, I have the same problem coming up soon.


            In my mind, I have it planned out such that I will use page flows to navigate around. This means that when you are done with the search page, you will also know which page to go back to. Consider the same scenario with a person search which could be called up from a number of different pages.


            In the page flow, when you make a transition (from order page to widget search) you can call an action method on the widget search bean that will set a flag which will indicate that this page allows you to add the item to the cart. In the widget search page you will only render the add to cart button if the flag is set. Once that method to add to the cart is called, the page flow can direct you back to the order page.


            This way you don't need to know which conversation you are since if a pageflow is tied to the conversation you won't even have to worry about it. That's the beauty of Seam coming with all these cool libraries out of the box and already integrated.


            As an FYI, regarding your original question, you can get the current conversation in a bean using :


            @In
            private Conversation conversation
            



            or in code using :


            Conversation.getInstance()
            




            Cheers,


            Andy