1 Reply Latest reply on Apr 17, 2008 9:59 PM by Caleb Land

    Redirecting to an existing natural conversation problem

    Caleb Land Newbie

      I'm using Seam 2.0.1.GA.


      When I try to join an existing natural conversation, I am getting an error that says that that the Conversation id is already in use. I tried to follow the seambay example closely, but with some adjustments.


      I created a simple project just to test this. There are two pages, accountEdit and accountList. The list page allows the user to create new accounts and displays the account list. From the list they can click an account to edit it.


      I want to create a new natural conversation when the user clicks an account from the list, and I would like to let them join an existing conversation if they leave the edit screen, and click the same account again.


      I have one action, and it's a subclass of EntityHome. The only model class, Account, has three fields, id, version, and username.


      Can anybody see what's wrong with what I'm doing?:


      The complete seam-gen project (40M)


      pages.xml:



      ...
      <conversation name="accountEdit" parameter-name="accountId" parameter-value="#{accountHome.longId}"/>
      
      <page view-id="/accountList.xhtml">
          <param name="id" value="#{accountHome.longId}"/>
      
          <navigation from-action="#{accountHome.editAccount}">
              <begin-conversation join="true" conversation="accountEdit"/>
              <redirect view-id="/accountEdit.xhtml"/>
          </navigation>
      </page>
      
      <page view-id="/accountEdit.xhtml" conversation="accountEdit">
          <navigation from-action="#{accountHome.persist}">
              <redirect view-id="/accountList.xhtml"/>
          </navigation>
      </page>
      ...




      accountList.xhtml:


      ...
      <h:form>
          <ui:repeat var="account" value="#{accounts}">
              <h:commandLink action="#{accountHome.editAccount}"
                             value="#{account.username}">
                  <s:conversationName value="accountEdit"/>
                  <f:param name="id" value="#{account.id}"/>
              </h:commandLink><br/>
          </ui:repeat>
      </h:form>
      
      <br/>
      <br/>
      <br/>
      
      <h:form>
        <h:panelGrid columns="2">
          <h:outputLabel for="name">User Name:</h:outputLabel>
          <h:inputText id="name" value="#{newAccount.username}"/>
        </h:panelGrid>
      
        <h:commandButton action="#{accountHome.createAccount}"
                         value="Create Account"/>
      </h:form>
      ...



      accountEdit.xhtml:



      ...
      <h:form>
        <h:panelGrid columns="2">
          <h:outputLabel for="name">User Name:</h:outputLabel>
          <h:inputText id="name" value="#{accountHome.instance.username}"/>
        </h:panelGrid>
      
        <h:commandButton action="#{accountHome.persist}"
                         value="Update Account"/>
      </h:form>
      ...



      and AccountHome.java:



      ...
      @Name("accountHome")
      @Scope(ScopeType.CONVERSATION)
      public class AccountHome extends EntityHome<Account> {
          @Logger Log log;
      
          public Long getLongId() { return (Long) this.getId(); }
          public void setLongId(Long id) { this.setId(id); }
      
          @Factory("newAccount")
          public Account getNewAccount() {
              return new Account();
          }
      
          @DataModel(scope = ScopeType.PAGE)
          List<Account> accounts;
      
          @Factory("accounts")
          public void accountsFactory() {
              this.accounts = this.getEntityManager().createQuery("select a from Account a").getResultList();
          }
      
          public void editAccount() {
          }
      
          public void createAccount() {
              this.instance = (Account) Contexts.lookupInStatefulContexts("newAccount");
              this.persist();
      
              this.accountsFactory();
          }
      }
      ...



      any ideas?