1 Reply Latest reply on Oct 21, 2008 2:30 PM by leon850515

    Conversation context still exists after ending the conversation

    leon850515

      1.I have a page which shows a list of entity, and there is a view and edit link for the entity. And the view and edit entity both involves several user interactions, so both are in the conversation scope and both have an init method which marked by annotations @Begin and @Create as belows:
      @Begin @Create
      public void init();


      2.In the view entity page, there is a create button for the entity(create entity and edit entity both have the same backing bean and the same page). The code is similiar to the belows:


      <s:button view="editEntity.xhtml" propagation="end" />




      3.In the edit entity page, after you modify the entity through serval user interaction pages, then you click save button, if the modified content is valid, then redirect to view entity page, and show the successfull message; if the modified content is invalid, then stay in the edit entity page, and show the corresponding error messages. The navigation rule for the succesful modification is as follows:


      <navigation from-action="#{entityEditController.save}">
          <rule if-outcome="SUCCESS">
              <end-conversation />
              <redirect view-id="/entityView.xhtml">
                  <param name="entityId" value="#{entityEditController.entity.id}" />
              </redirect>
          </rule>
      </navigation>



      4.I write a conversation listener for checking the beginning and ending of the conversation as a forum post said as belows.


      @Stateless
      @Name("conversationListener")
      public class ConversationListenerController implements ConversationListener {
              
              @Logger 
              private Log log;
              
              @Observer(value="org.jboss.seam.beginConversation")
              public void observerConversationStart() {
                      log.info("11111111111111111111 Conversation Started");
              }
              
              @Observer(value="org.jboss.seam.endConversation")
              public void observerConversationEnd() {
                      log.info("11111111111111111111 Conversation Ended");
              }
      }



      My understanding is that:
      When you click view link in entity list page, the long-running conversation for the view entity backing bean begins. Then in the processor of the view entity , you click the create entity button, the long-running conversation for the view entity will be demoted to temporary conversation, the context in the view entity backing bean will be destroyed. And the long-running conversation for the edit entity backing bean begins, the you assign valid value to the entity, at last click the save button, then the long-running conversation for the create entity will be demoted to temporary conversation, the context in the edit entity backing bean will be destroyed. And the the page is redirected to the entity view page, the long-running conversation for the view entity backing bean begins. But according to the log, now the conversation for the view entity backing bean doesn't begin. But you can see the view entity page shows the previous viewd entity not the created entity for view, does it mean the context for previous viewd entity not destroy?


      From the user point of view, in the entity list page, click to view an entity named A, then in the process
      of the view entity A page, click the create button to create an entity named B, at last click the save button, then it will be redirect to the view entity B page, but now it is still in the view entity A page.


      Then I change the navigation rule for the successful modification, change from
      <end-conversation />
      to
      <end-conversation before-redirect="true" />
      , it can be successfully redirectd to view entity B page, but now the successful creating entity B message disappeard. Because the facesMessage is in the conversation scope, and after you explicitly end conversation before redirect, the facesMessage component is destoryed.


      Does anyone have any advice on it?