2 Replies Latest reply on Mar 24, 2009 3:29 PM by israel.bgf

    How to instantly destroy a conversation?

    israel.bgf

      Is there any way to instantly destroy the actual (long-running or not) conversation? I mean, something like: Conversation.instance().immediateEnd().


      Thks, Israel

        • 1. Re: How to instantly destroy a conversation?
          joblini

          Hi Isreal, I think you may find what you need here


          Something like



          Conversation.instance().end(true)

          • 2. Re: How to instantly destroy a conversation?
            israel.bgf
            Thks for the thread Ingo, but it still doesnt solve my problem. Look my example:

            My page

                 <h:form id="form">
                      Value: <h:outputText value="#{test.value}"/><br/>
                      Input: <h:inputText value="#{test.value}"/><br/>
                      <h:commandButton action="#{test.redirect}" value="Redirect"/>
                      <h:commandButton action="#{test.redirectAndEndBeforeIt}" value="Redirect and End"/>
                      <h:commandButton action="#{test.postback}" value="Postback"/>
                      <h:commandButton action="#{test.endBeforePostback}" value="End before Postback"/>
                      <h:commandButton action="#{test.endBeforePostbackAlternative}" value="End before Postback Alternative"/>
                 </h:form>

            My test Class


            @Name("test")
            @Scope(ScopeType.CONVERSATION)
            public class Test {

                 private String value;

                 //Should not work just to test it
                 @End
                 public void end(){
                 }
                 
                 //I dont know if it should work, but it doesnt anyway.
                 @End(beforeRedirect=true)
                 public void endBeforeRedirect(){
                 }
                 
                 //Should not work too.
                 public void postback(){
                 }

                 //I think that should, but it doenst too.
                 public void endBeforePostback(){
                      Conversation.instance().end();
                      Conversation.instance().leave();
                 }
                 
                 //The only solution that i find, but what happens if i want to destroy all
                 //the objects in this current conversation?
                 public void endBeforePostbackAlternative(){
                      Contexts.getConversationContext().remove(getMyName());
                 }
                 
                 public void setValue(String value) {
                      this.value = value;
                 }

                 public String getValue() {
                      return value;
                 }
                 
                 private String getMyName(){
                      Annotation an = this.getClass().getAnnotation(Name.class);
                      return ((Name) an).value();
                 }
                 
            }


            In this example i try to find a way to place a text in the input, and do not show it afterward. Why do i want this? I use a lot of ajax in my pages, and i dont like/want to use different pages, CRUDs in fact are all in one page, so i need to control the conversation and be able to destroy it right away, to re-render a part of the page with fresh values.

            The only way that i found is the endBeforePostbackAlternative, but.. what if i want to clear all the objects in the current conversation? I wanted something generic to do this job. Any idea?

            And thks again! o>