3 Replies Latest reply on Aug 28, 2008 4:24 PM by David D

    2 pages, 2 conversations

    David D Newbie

      Hi,
      Maybe it is a totally idiot question but...
      I'd like to have two tabs (two xhtml pages), each one having its own long running conversation. Because I want to be able to timeout one tab for memory consumption matters. But the user can switch between tabs and get its conversation back while it has not timed out.
      I tried many things today, including natural conversations, but i really cannot get any result...


      Here is what i tried last:



          <page view-id="/test/tab1.xhtml" login-required="false" conversation="conv1">
              <description>TAB 1: #{convId1}</description>
              
              <navigation from-action="#{test1.doSomething()}" />
              
              <navigation from-action="#{test2.tab2()}">
                <begin-conversation join="true" />
                <redirect view-id="/test/tab2.xhtml"/>
              </navigation>
          </page>
          <page view-id="/test/tab2.xhtml" login-required="false" conversation="conv2">
              <description>TAB 2: #{convId2}</description>
              
              <navigation from-action="#{test2.doSomething()}" />
              
              <navigation from-action="#{test1.tab1()}">
                <begin-conversation join="true" />
                <redirect view-id="/test/tab1.xhtml"/>
              </navigation>
          </page>




      and tab1.xhtml for example:



      <s:link action="#{test2.tab2()}" value="tab 2" conversationName="conv2" />
      



      thanks

        • 1. Re: 2 pages, 2 conversations
          David D Newbie

          Seems like that was an idiot question... I found something but it is not working since the conversation is the same


          tab1.xhtml:


          <s:link action="#{test2.goto2()}" value="tab 2" />
          <h:outputText value="#{manager.instance().getCurrentConversationId()}" />
          <h:outputText value="#{manager.instance().getCurrentConversationDescription()}" />




          tab2.xhtml:


          <s:link action="#{test1.goto1()}" value="tab 1" />
          <h:outputText value="#{manager.instance().getCurrentConversationId()}" />
          <h:outputText value="#{manager.instance().getCurrentConversationDescription()}" />



          pages.xml:


              <conversation name="ctab1" parameter-name="c1" parameter-value="1" />
              <conversation name="ctab2" parameter-name="c2" parameter-value="2" />
          
              <page view-id="/home.xhtml">
                  <navigation from-action="#{test1.goto1()}">
                      <begin-conversation join="true" conversation="ctab1" />
                      <redirect view-id="/conv/tab1.xhtml" />
                  </navigation>
              </page>
          
              <page view-id="/conv/tab1.xhtml" conversation="ctab1">
                  <description>Tab 1</description>
                  <navigation from-action="#{test2.goto2()}">
                      <begin-conversation join="true" conversation="ctab2" />
                      <redirect view-id="/conv/tab2.xhtml" />
                  </navigation>
              </page>
          
              <page view-id="/conv/tab2.xhtml" conversation="ctab2">
                  <description>Tab 2</description>
                  <navigation from-action="#{test1.goto1()}">
                      <begin-conversation join="true" conversation="ctab2" />
                      <redirect view-id="/conv/tab1.xhtml" />
                  </navigation>
              </page>



          Test1.java:


          @Name("test1")
          @Scope(ScopeType.CONVERSATION)
          public class Test1
          {
              public void goto1()
              {
                  System.out.println("------ Test1.goto1: " + this + "/" + Conversation.instance());
          
                  ConversationEntry entry = ConversationEntries.instance().getConversationEntry("ctab1:1");
                  System.out.println("ctab1:1 = " + entry);
          
                  if (entry != null)
                  {
                      System.out.println("selecting ctab1:1");
                      entry.select();
                  }
              }
          }



          Test2.java:


          @Name("test2")
          @Scope(ScopeType.CONVERSATION)
          public class Test2
          {
              public void goto2()
              {
                  System.out.println("------ Test2.goto2: " + this + "/" + Conversation.instance());
          
                  ConversationEntry entry = ConversationEntries.instance().getConversationEntry("ctab2:2");
                  System.out.println("ctab2:2 = " + entry);
          
                  if (entry != null)
                  {
                      System.out.println("selecting ctab2:2");
                      entry.select();
                  }
              }
          }
          





          on tab1, i got:



          1. cID:ctab1:1

          2. cDesc:Tab 1



          and on tab2:



          1. cID:ctab2:2

          2. cDesc:Tab 2



          but


          ConversationEntries.instance().getConversationEntry("ctab1:1")



          and


          ConversationEntries.instance().getConversationEntry("ctab2:2")



          return both the same entry...


          How to have 2 different conversations ???
          Thanks

          • 2. Re: 2 pages, 2 conversations
            David D Newbie

            Well i finally found some way to make it work...


            Add propagation=none on the link:


            <s:link action="#{test2.goto2()}" value="tab 2" propagation="none"/>



            put a begin-conversation in the navigation rule and without join=true:


            <page view-id="/conv/tab1.xhtml" conversation="ctab1">
                <description>Tab 1</description>
                <navigation from-action="#{test2.goto2()}">
                    <begin-conversation  />
                    <redirect view-id="/conv/tab2.xhtml" />
                </navigation>
            </page>
            



            so it works... until now...

            • 3. Re: 2 pages, 2 conversations
              David D Newbie

              now has arrived. in fact the conversation is the same but the bean is destroyed and recreated each time.