2 Replies Latest reply on Aug 29, 2013 2:42 AM by thiagu.mr

    End Conversation is not working for Natural conversation

    thiagu.mr

      I want to represent the data in tab panel in the page.

      The user can concurrently work on this tab section by open it in separate browser tabs.

      I am using natural conversation in this page.

      The sample code is below,

       

      The natural conversation is defined as like in my pages.xml

       

      <conversation name="userId" parameter-name="userId" parameter-value="#{homeAction.uid}"/>

       

      And I used this defined conversation in my home.page.xml as like

       

      <page login-required="true" conversation="userId"> 

       

      <restrict>#{authorization.hasRole()}</restrict>

       

      <begin-conversation join="true" flush-mode="manual"/>

       

      <param name="userId" value="#{homeAction.uid}"/>

       

      <action execute="#{homeAction.init}" on-postback="false"/>

       

      <navigation>

      <rule if-outcome="END">

      <end-conversation before-redirect="true"/>

      <redirect view-id="/home/home.xhtml"/>

      </rule>

      </navigation>

       

      </page>


      my home.xhtml as like

       

      <h:form>

      <rich:tabPanel selectedTab="#{homeAction.selectedTab}">

      <c:forEach items="#{homeAction.users}" var="item">

      <rich:tab name="#{item.userName}" action="#{homeAction.oneTabChange}">

      <f:facet name="label">#{item.userName}</f:facet>

      <f:param name="userId" value="#{item.id.uid}"/>

      <h:panelGrid columns="2">

      userName: #{item.userName}

      passWord: #{item.passWord}

      </h:panelGrid>

      </rich:tab>

      </c:forEach>

      </rich:tabPanel>

      </h:form>

       

      And my HomeAction class looks like as blow

       

      @Scope(ScopeType.CONVERSATION)

      @Name("homeAction ")

      public class HomeAction {

       

      @In(create=true)

      private EntityManager entityManager;

       

      private String selectedTab;

       

      private int uid = -1;

       

      private List<UmuserMaster> users;

       

      public void init() {

       

      initUserList(); 

       

      intiSelectedTab(); 

      }

       

       

      private void intiSelectedTab() {

      String userName = null;

      if(uid == -1 && (users != null && !users.isEmpty())){

      userName = users.get(0).getUserName();

      }else{

      userName = (String)entityManager.createQuery("select um.userName from UmuserMaster um " +

      "where um.id.uid = :uid")

      .setParameter("uid", uid)

      .getSingleResult();

      }

      setSelectedTab(userName);

      }

       

      private void initUserList() {

      users = entityManager.createQuery("from UmuserMaster um").getResultList();

      }

       

      public String oneTabChange(){  

      return “END”; 

      }

       

      public String getSelectedTab() {

      return selectedTab;

      }

       

      public void setSelectedTab(String selectedTab) {

      this.selectedTab = selectedTab;

      }

       

       

      public int getUid() {

      return uid;

      }

       

      public void setUid(int uid) {

      this.uid = uid;

       

      public List<UmuserMaster> getUsers() {

      return users;

      }

      }

       

      If the user switches from one tab to other, I am ending the current conversation before redirect and the new conversation created before the page redirect.

       

      Now I am facing the problem with conversation end. It is not ending the natural conversation as expected.

      So my previous natural conversation is marked as background conversation, and it is destroyed after conversation timeout elapsed (2 min).

       

      Any suggestion how to end the natural conversation in my case?





        • 1. Re: End Conversation is not working for Natural conversation
          manarh

          Did you launch flush() as it is described in documentation? Seam - Contextual Components

           

          Do you really need to use flush-mode="manual" ?

          • 2. Re: End Conversation is not working for Natural conversation
            thiagu.mr

            Thank you for the replay.

             

            Yes we no need the “flush-mode="manual” here.

             

            As per my understating the my issue because of parameter-value="#{homeAction.uid}" from conversation definition.

            When I come to home page first time, the conversation is started before the “Invoke application” phase.  So the seam starts the conversation with the default value (userId:-1).

             

            The “uid” initialized after the begin conversation. Since the “uid” is not -1 When I switch to other tab, seam not able to restore my conversation(userId:-1) in the restore view phase, so it is not able to end the conversation.