6 Replies Latest reply on Mar 23, 2009 6:09 PM by Adrien FERIAL

    Ending natural conversation fails

    Bernard Labno Master

      I have strange problem. I want to start 2 conversations on entering 2 pages.
      User should have only one such conversation per page. Natural conversations
      seam to be the right choice. However problem arises when I remove such
      conversation via #{entry.destroy}. It gets destroyed, but a new conversation
      gets created right away. When I'm on usersList.xhtml and remove itemsList
      a new usersList conversation gets created. When I'm on itemsList.xhtml
      and remove usersList then itemsList conversation gets created. This
      seems to be triggered by pages.xhtml. All works fine when I'm on index.xhtml
      and remove those conversations. What am I doing wrong ?


      pages.xhtml :


      <?xml version="1.0" encoding="UTF-8"?>
      <pages xmlns="http://jboss.com/products/seam/pages"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://jboss.com/products/seam/pages
             http://jboss.com/products/seam/pages-2.1.xsd">
          
          
          <page view-id="/usersList.xhtml" conversation="UsersList">
              <description>#{messages.usersList}</description>
              <begin-conversation join="true"/>
          </page>
          <page view-id="/itemsList.xhtml" conversation="ItemsList">
              <description>#{messages.categoriesList}</description>
              <begin-conversation join="true"/>
          </page>
          <conversation name="UsersList" parameter-name="cid" parameter-value="1"/>
          <conversation name="ItemsList" parameter-name="zid" parameter-value="1"/>
      
      </pages>



      template.xhtml :


      <?xml version='1.0' encoding='UTF-8' ?> 
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
            xmlns:ui="http://java.sun.com/jsf/facelets"
            xmlns:s="http://jboss.com/products/seam/taglib"
            xmlns:h="http://java.sun.com/jsf/html"
            xmlns:f="http://java.sun.com/jsf/core">
          
          <head>
              <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
              <link href="./css/default.css" rel="stylesheet" type="text/css" />
              <link href="./css/cssLayout.css" rel="stylesheet" type="text/css" />
              <title>EndNaturalConversation</title>
          </head>
          
          <body>
              <div id="left">
                  <s:link propagation="none" view="/index.xhtml" value="Home"/><br />
                  <s:link conversationName="UsersList" view="/usersList.xhtml" value="Users list"/><br />
                  <s:link conversationName="ItemsList" view="/itemsList.xhtml" value="Items list"/><br />
                  <hr />
                  <h:form>
                      <h:dataTable value="#{conversationList}" var="entry">
                          <h:column>
                              <h:commandLink action="#{entry.select}" value="#{entry.description}" rendered="#{!entry.current}"/>
                              <h:outputText value="#{entry.description}" rendered="#{entry.current}"/>
                              <h:outputText value="[current]" rendered="#{entry.current}"/>
                          </h:column>
                          <h:column>
                              <h:outputText value="#{entry.startDatetime}">
                                  <f:convertDateTime type="time" pattern="HH:mm"/>
                              </h:outputText>
                          </h:column>
                          <h:column>
                              <h:outputText value="#{entry.lastDatetime}">
                                  <f:convertDateTime type="time" pattern="HH:mm"/>
                              </h:outputText>
                          </h:column>
                          <h:column>
                              <h:commandLink value="end" action="#{entry.destroy}" rendered="#{!entry.current}">
                                  <s:conversationPropagation type="none" />
                              </h:commandLink>
                          </h:column>
                      </h:dataTable>
                  </h:form>
              </div>
              <div id="content" class="left_content">
                  <ui:insert name="content">Content</ui:insert>
              </div>
              
          </body>
          
      </html>
      



      itemsList.xhtml :


      <?xml version='1.0' encoding='UTF-8' ?>
      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                      xmlns:ui="http://java.sun.com/jsf/facelets"
                      xmlns:h="http://java.sun.com/jsf/html"
                      template="./template.xhtml">
          
          <ui:define name="content">
              <h:form>
                  <h:dataTable value="#{items}" var="item">
                      <h:column>
                          #{item.name}
                      </h:column>
                  </h:dataTable>
              </h:form>
          </ui:define>
      
      </ui:composition>
      


      usersList.xhtml :


      <?xml version='1.0' encoding='UTF-8' ?>
      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                      xmlns:ui="http://java.sun.com/jsf/facelets"
                      xmlns:h="http://java.sun.com/jsf/html"
                      template="./template.xhtml">
          
          <ui:define name="content">
              <h:form>
                  <h:dataTable value="#{users}" var="user">
                      <h:column>
                          #{user.username}
                      </h:column>
                  </h:dataTable>
              </h:form>
          </ui:define>
      
      </ui:composition>
      



      DataStore.java :


      package endnaturalconversation;
      
      import java.util.ArrayList;
      import java.util.List;
      import org.jboss.seam.annotations.Factory;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Out;
      
      @Name("dataStore")
      public class DataStore {
      
          @Out(required=false)
          List<User> users;
          
          @Out(required=false)
          List<Item> items;
          
          @Factory
          public void getUsers() {
              users = new ArrayList<User>();
              users.add(new User("Jack"));
              users.add(new User("Stan"));
              users.add(new User("Don"));
          }
          
          @Factory
          public void getItems() {
              items = new ArrayList<Item>();
              items.add(new Item("Belt"));
              items.add(new Item("Shoe"));
              items.add(new Item("Tie"));
          }
      }
      

        • 1. Re: Ending natural conversation fails
          Bernard Labno Master

          Ok, the problem is joining:


          <page view-id="/usersList.xhtml" conversation="UsersList">
             <description>#{messages.usersList}</description>
             <begin-conversation join="true"/>
          </page>



          When I remove begin-conversation from pages.xml and start conversation with @Begin method, then destroying conversations works. The problem now is that when I hit the link that invokes @Begin method then page is rendered, but no entry appears in workspace management table. It will appear on next rendering. How can I make it appear at once ?
          When is the conversationList updated ?


          Another bug ( and it is a bug for sure ) is in ConversationEntry :


          public void destroy() 
          {
             boolean success = Manager.instance().switchConversation( getId() );
             if (success) Manager.instance().endConversation(false);
          }



          After this method the conversation id is wrong ! We could have destroy one conversation from another and guess which conversation's id will appear if we try to render ? The removed conversation's ! We just removed once conversation and  got kicked out of another.


          Seam 2.1.0.A1

          • 2. Re: Ending natural conversation fails
            Pete Muir Master

            Please try with Seam 2.1 BETA as it contains many fixes. If you are still having problems, file issues in JIRA with an example to reproduce.

            • 4. Re: Ending natural conversation fails
              Bernard Labno Master

              Hey guys, any progress on this issue ? I'm currently using Seam 2.1.0.BETA1. Navigating between natural conversations via conversation table still leaves lots to wish. Now when I'm in a natural conversation A and destroy conversation B, a new conversation A is not created (as in previous release) but i'm kicked out to some other page, and I should be staying on page from conversation A.
              (Note that i'm having <begin-conversation type=join/> in pages.xml for both pages of conversations A and B).


              BTW. what is your proposition for requirement like this : administrator must have menu with 3 links starting conversations for managing 3 types of entities. Those links should allow escaping some pageflow and starting those 3 conversations. How to do this ? From my experience <begin-conversation type=join/> causes troubles, and putting s:links in menu with propagation different then none does not allow to escape pageflows. Any suggestions ?

              • 5. Re: Ending natural conversation fails
                Marc Minnee Newbie

                I have an issue somewhat related. I use a menu to start a conversation, from which I start a nested conversation. Suppose the user makes a mistake and wants to start all over again by pressing the menu button again. I noticed a 'sticky' conversation context, even when I explicitly call the SFSB's destroy method.
                How to do this right?

                • 6. Re: Ending natural conversation fails
                  Adrien FERIAL Newbie

                  Marc Minnee wrote on Sep 16, 2008 16:11:


                  I have an issue somewhat related. I use a menu to start a conversation, from which I start a nested conversation. Suppose the user makes a mistake and wants to start all over again by pressing the menu button again. I noticed a 'sticky' conversation context, even when I explicitly call the SFSB's destroy method.
                  How to do this right?


                  Same wondering...