1 Reply Latest reply on Mar 9, 2010 8:14 PM by asookazian

    Conversation scope - when to end it

    oneworld95

      Here's what my app does and I'm wondering if the conversation scope is a better way to do this:



      1. User clicks link on the home page to bring up a Seam/Richfaces form.

      2. They fill the form and click Submit.

      3. Seam sends the form info as an email.

      4. When the email is sent successfully, the app redirects to the home page and displays a message saying Email sent Successfully.



      One issue I've noticed is that when the user goes back to the same form, because I'm using session scope for the Seam component, the values s/he had entered are still there. I'd like to use conversation scope to better handle the app's needs and to make this into a transaction.


      How do you end a conversation when the email is sent successfully? This should destroy the Seam component. Thanks.


        • 1. Re: Conversation scope - when to end it
          asookazian

          Typically conversation scope is used in multiple HTTP request/response cycles like a wizard or multi-page form, etc.


          Do you have multiple HTTP request/response cycles in this use case (i.e. multiple form submissions)?  If yes, then you can model this using a JavaBean or SFSB with conversation scope as the backing bean for your JSF view.  But it sounds like your use case spans one or two pages maximum.  Request scope may be suitable here.  After step 1, is the user still on the first page or a different page?


          @Begin promotes a temporary conversation to long-running (LRC).  The @End demotes to temporary (for eventual destruction).


          Read the ref doc or SiA book for more details.  See the hotel booking example as well.