1 Reply Latest reply on Jul 11, 2008 7:29 PM by pmuir

    Conversations, Wizards, and Home objects

    gzoller.greg.zoller.aviall.com

      Hello,


      I'm trying to do something pretty straightforward.  I want a 2 or 3 screen wizard that will populate and entity object that gets persisted at the end of the wizard.  Sounds like a job for a conversation.


      I start my conversation in a page.xml file:



         <begin-conversation join="true"/>
      



      I've taken my default seam-gen'ed Home object and added annotations to make it conversation-scoped:


      @Scope(ScopeType.CONVERSATION)
      @Name("custorderHome")
      public class CustorderHome extends EntityHome<Custorder> {
      
           @In(create = true)
           AddressHome addressHome;
           @In(create = true)
           UserHome userHome;
      
      ...



      Ok, so now the UI.  I have a page like below; the first screen of my wizard:



      <!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:s="http://jboss.com/products/seam/taglib"
                      xmlns:ui="http://java.sun.com/jsf/facelets"
                      xmlns:f="http://java.sun.com/jsf/core"
                      xmlns:h="http://java.sun.com/jsf/html"
                      xmlns:rich="http://richfaces.org/rich"
                      template="layout/template.xhtml">
                             
      <ui:define name="body">
          
          <h:messages globalOnly="true" styleClass="message" id="globalMessages"/>
      
          <h:form id="wiz1" styleClass="edit">
      
          <rich:panel>
              <f:facet name="header">New Order Wizard (1 of 3)</f:facet>
      
              <s:decorate id="active" template="layout/display.xhtml">
                  <ui:define name="label">Order for User</ui:define>
                     <h:selectOneMenu id="selectUser"
                           value="#{custorderHome.instance.user}">
                          <s:selectItems value="#{userList.resultList}" var="user" 
                               label="#{user.name}" 
                               noSelectionLabel="Select User"
                               hideNoSelectionLabel="1" />
                          <s:convertEntity/>
                     </h:selectOneMenu> 
              </s:decorate>
              <p/>
          </rich:panel>
          
          <div class="actionButtons">      
              <s:button view="/Wizard_2.xhtml" 
                          id="next" 
                       value="Next"/>
      
              <s:button view="/home.xhtml"
                          id="cancel"
                       value="Cancel"/>
          </div>
          </h:form>
      </ui:define>
      
      </ui:composition>
      



      So far, so good.  When run I do get a nice pull-down populated with users as I expect, but... when I hit Next to go to wizard page 2 something doesn't carry over--my User assignment from page 1 isn't visible.  In page 1 the pull down is supposed to select and populate a User from the list but on page 2 if I have code like the following I see displayed true, false, (nothing), and (nothing) respectively:


      Managed: #{custorderHome.managed}
      Wired: #{custorderHome.wired}
      Id: #{custorderHome.instance.idcustOrder}
      User: #{custorderHome.instance.user.name}
      



      What am I not doing right?  I go to the debug.seam screen and can validate that a conversation has been created, a custorderHome object exists in that conversation, but the instance is empty (non-null, but not populated) there too.


      Thanks for any help,
      Greg