4 Replies Latest reply on May 15, 2010 11:59 PM by asookazian

    how to end and begin conversation on entering page?

    deanhiller2000

      we have two urls xxxx/newticket and xxxx/ticket/1342


      in both instances, users can go directly to this url and we need to end the conversation and begin a new one.  I can't add @End and @Begin to a method, can I?  or end-conversation in the page and @Begin in the method.


      This goes back to an issue I filed where @Begin should have a param of end previous conversation(and the default should nearly always be true to end any previous conversations).


        • 1. Re: how to end and begin conversation on entering page?
          babazs

          You should end the conversation when you leave the previous page(rule,endconversation,redirect in the pages.xml), then add begin-conversation in the pages.xml of the new page.

          • 2. Re: how to end and begin conversation on entering page?
            amitev

            Or use the following workaround


                 /**
                  * Kills the existing and begins a new long-running conversation.
                  */
                 protected void endExistingAndStartNewConversation() {
                      String convID = Conversation.instance().getId();
                      Conversation.instance().leave();
                      Conversation.instance().begin();
                      Lifecycle.destroyConversationContext(getSessionMap(), convID);
                      ConversationEntries.instance().removeConversationEntry(convID);
                 }
            
                 /**
                  * Returns a holding session entries.
                  * 
                  * @return the session map.
                  */
                 private Map<String, Object> getSessionMap() {
                      // this method could be moved to a utility class
                      Map<String, Object> session = new HashMap<String, Object>();
                      String[] sessionAttributeNames = Contexts.getSessionContext()
                                .getNames();
            
                      for (String attributeName : sessionAttributeNames) {
                           session.put(attributeName, Contexts.getSessionContext().get(
                                     attributeName));
                      }
                      return session;
                 }
            
            

            • 3. Re: how to end and begin conversation on entering page?
              yahawari

              is this related ?


              My Link

              • 4. Re: how to end and begin conversation on entering page?
                asookazian

                Yes, it's related to that thread.  The bottom line on that from PMuir is this:


                @End(beforeRedirect=true) for this purpose. No, there is no way to end and start a new conversation without doing a redirect, and no, we aren't planning to implement such a function in core Seam. Someone should write a wiki article showing how to do this, with a custom component :-)