6 Replies Latest reply on Jan 19, 2010 5:29 AM by cilgamir

    Restart Conversation

    cilgamir

      Hi


      I would like to know how to restart a conversation.


      I want to do this because I need to reset the state of a bean used to populate an ICEfaces form. If someone submits a form he is redirected to a page where he can choose to fill in the form again with different details.


      Currently my command button does this



              <ice:commandButton value="Yes" action="#{kycRequestSuccessful.newRequest()}">
                      <s:conversationPropagation type="end"/>
                      <s:conversationPropagation type="start"/>
              </ice:commandButton>
      




      Obviously that hack fails, it gives me a No active conversation context Exception.


        • 1. Re: Restart Conversation
          cilgamir

          I see now that the bean that I want to reset has a ScopeType of SESSION and not CONVERSATION.


          I don't know if restarting the conversation would to the trick.


          If I change the bean ScopeType to CONVERSATION then most things break.


          Any ideas ?

          • 2. Re: Restart Conversation
            cilgamir

            Even if I try to manually reset the instance variables to null, or whatever they started as, I cant seem to do it.


            In a non-seam icefaces application thise would work fine




            ((KycRequestBusinessUnitController)FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("kycRequestBusinessUnitController")).resetBean();





            But I cant seem to call the resetBean() method without some serious exceptions



            FATAL [javax.enterprise.resource.webcontainer.jsf.application] javax.ejb.EJBTransactionRolledbackException: org.javassist.tmp.java.lang.Object_$$_javassist_2




            • 3. Re: Restart Conversation
              cilgamir

              The best I can come up with is to reset the fields before navigating away from the page, just after persisting them to the database. That seems to work fine.


              Seam really is a pain in my ass, it's supposed to make life easier, but sometimes having more control is a good thing. It's my fault for not learning the tech before trying to use it.


              Thanks for all the help ;)

              • 4. Re: Restart Conversation
                jguglielmin

                I'm not sure exactly what your use case is, but if you might want to consider a specific instance or use of an entity within a single conversation.  If you still want to work on that entity, then stay within the conversation (or nest it--but that can give unexplained results if you are not experienced with Seam).  If you have want to work with a different instance of that entity, then you want to end the conversation (SMPC takes care of all the stuff in behind to make that easier) and then start a new conversation for the new instance. For detailed help with Seam and ICEfaces, you should try the ICEfaces forums.

                • 5. Re: Restart Conversation
                  kragoth

                  Hannes Visagie wrote on Jan 18, 2010 06:31:


                  Hi

                  I would like to know how to restart a conversation.

                  I want to do this because I need to reset the state of a bean used to populate an ICEfaces form. If someone submits a form he is redirected to a page where he can choose to fill in the form again with different details.

                  ....

                  If I change the bean ScopeType to CONVERSATION then most things break.



                  The problems you are having have nothing to do with Seam, but with your design.
                  Seam sopes exist for a purpose. Just like in plain java you don't make a variable final if you want to change it the same applies to Seam. Don't make a bean Session scoped if you want to reset it.


                  If changing the bean to Conversation scope breaks  your app then fix the reason why it breaks the app. Don't just leave it as Session and complain about Seam. Learning Seam conversations and how to use them and how to do navigation around them is hard to get right. I personally find Seam navigation with regards to conversations (ending and beginning a new one) extremely fragile and too restrictive (in that you must do things a particular way or it just wont work, but that particular way is not defined very well).


                  If you are really serious about using Seam in your application then there really is nothing you can do but take the time to learn how to use it. But, at least start with reading the doco about the Scopes and then go look at the Seam examples. Then write small pages to do what you want to do and get a grasp of how things work together.


                  Us forum readers will try to help you when you come across a problem, but you have to put the initial effort in to at least get some understanding of the technology. Otherwise our explanations are not going to make much sense.

                  • 6. Re: Restart Conversation
                    cilgamir

                    Thanks Tim, Judy.


                    I'm working on a system that is already in production, so using seam was not my choice. But it's always nice to come accross something new.


                    I'll take the time to learn how seam works.


                    Thanks for the advice.


                    H