1 Reply Latest reply on Jan 5, 2008 8:40 AM by pmuir

    Newbie conversation question

    utdrew

      I'm having a hard time getting seam to start conversations when I want it to. I have a series of pages that go with a type of task. Using facelets I've created a special navigation bar for each task. This bar has a series of links that can be clicked on at any time that the user is working with that type of task. A couple of the links open 'wizards' for creating new things. What I would like to have happen is that every time a user clicks one of these links a new conversation is started and the first page of the wizard opens. I've tried this a couple of different ways and haven't had much luck

      Here is my stateful wizard bean

      @Stateful
      @Name("feeProductWizard")
      public class FeeProductWizardBean implements FeeProductWizard {
      
       @Logger private Log log;
      
       @Out
       private FeeProduct feeProduct;
      
       @In
       private FacesMessages facesMessages;
      
       @In
       private FeeConfiguratonHandler feesConfigBean;
      
       @In(create=true)
       private FeeSearcher feeSearcher;
      
       @Resource(mappedName="java:/FeeEntityManager")
       private EntityManager em;
       /** Whether the product is valid or not */
       private boolean feeProductValid;
       /** The set of default assessment notes */
       private Hashtable<Integer,String> defaultAssessmentNotes;
      
       @SuppressWarnings("unchecked")
       @Create
       public void init() {
       defaultAssessmentNotes = feesConfigBean.getDefaultNotes();
       log.info("default assessment notes = " + defaultAssessmentNotes);
       }
      
       /**
       * @see com.emida.intranet.fees.wizard.NewWizard#startNewWizard()
       */
       @Begin
       public void startNewWizard() {
       log.info("Starting new fee product wizard");
       feeProduct = new FeeProduct();
       }
      
       /**
       * @see com.emida.intranet.fees.wizard.NewWizard#back()
       */
       public void back() {
       }
      
       /**
       * @see com.emida.intranet.fees.wizard.NewWizard#next()
       */
       public void next() {
       log.info("next called : " + feeProduct);
       }
      
       /**
       * @see com.emida.intranet.fees.wizard.FeeProductWizard#validateDates()
       */
       public void validateDates() {
       log.info("validating dates");
       if(feeProduct.getEndDate() != null) {
       if(feeProduct.getStartDate().compareTo(feeProduct.getEndDate()) >= 0) {
       log.debug("end date is after start date");
       facesMessages.addToControl("endDate", "#{messages.endDateError}");
       feeProductValid = false;
       }else {
       feeProductValid=true;
       }
       }else {
       feeProductValid=true;
       }
       }
      
       /**
       * @see com.emida.intranet.fees.wizard.FeeProductWizard#isFeeProductValid()
       */
       public boolean isFeeProductValid() {
       return feeProductValid;
       }
      
       /**
       * @see com.emida.intranet.fees.wizard.NewWizard#cancel()
       */
       @End
       public void cancel() {
       }
      
       /**
       * @see com.emida.intranet.fees.wizard.NewWizard#destroy()
       */
       @Remove
       @Destroy
       public void destroy() {
       }
      
       /**
       * @see com.emida.intranet.fees.wizard.NewWizard#saveNew()
       */
       @End
       public void saveNew() {
       em.persist(feeProduct);
       }
      
       /**
       * @see com.emida.intranet.fees.wizard.FeeProductWizard#setupDefaultNote()
       */
       public void setupDefaultNote() {
       FeeProductSearchConfig config = new FeeProductSearchConfig();
       config.setFeeName(feeProduct.getFeeName());
       if(feeSearcher.doFeeProductSearch(config).size() != 0) {
       log.debug("fee name has been taken");
       facesMessages.addToControl("feeName", "#{messages.feeNameError}");
       feeProductValid = false;
       }else {
       feeProductValid=true;
       }
       feeProduct.setFeeAssessmentNote(defaultAssessmentNotes.get(feeProduct.getFeeCriteriaType().ordinal()));
       }
      }
      
      


      This is the facelets fragment for the navigation bar

      ?xml version="1.0" encoding="ISO-8859-1" ?>
      
      <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:c="http://java.sun.com/jstl/core"
       xmlns:a4j="http://richfaces.org/a4j"
       xmlns:rich="http://richfaces.org/rich"
       xmlns:intra="http://www.emida.net/intranet"
       xmlns:s="http://jboss.com/products/seam/taglib"
       version="2.0">
      
      <ui:composition>
      <f:loadBundle var="feesNav" basename="fees.GeneralFeeMessages" />
      <rich:panel>
      
      <table class="sidebar">
       <tr>
       <td> <font size="-2">
       <h:form id="navForm">
       <h:panelGrid columns="1" cellpadding="2" cellspacing="2">
       <f:facet name="header">
       <h:outputText value="#{feesNav.feesHeader}"/>
       </f:facet>
       <h:outputText styleClass="sectionHeader" value="#{feesNav.manageFeeAgreements}"/>
       <h:outputLink value="/intranet/fees/feeAgreement/search.seam">
       <h:outputText value="[#{feesNav.searchFeeAgreements}]" />
       </h:outputLink>
       <h:commandLink id="newFeeAgreement" value="[#{feesNav.createNewFeeAgreement}]"
       action="#{feeAgreementWizard.startNewWizard}" />
       <h:outputText styleClass="sectionHeader" value="#{feesNav.manageFeeProducts}"/>
       <h:outputLink value="/intranet/fees/feeProduct/search.seam">
       <h:outputText value="[#{feesNav.searchFeeProducts}]" />
       </h:outputLink>
       <h:commandLink id="newFeeProduct" value="[#{feesNav.createNewFeeProduct}]"
       action="#{feeProductWizard.startNewWizard}" />
       <h:outputText styleClass="sectionHeader" value="#{feesNav.misc}"/>
       <h:outputLink value="/intranet/fees/approveFees.seam">
       <h:outputText value="[#{feesNav.approveFees}]" />
       </h:outputLink>
       </h:panelGrid>
       </h:form>
       </font>
       </td>
       </tr>
      </table>
      </rich:panel>
      </ui:composition>
      </jsp:root>
      


      I first tried using the s:link tag to start the wizard but for some reason I had to click the link twice before it would call the action method. The code for that was:

      <s:link id="newFeeProduct" value="[#{feesNav.createNewFeeProduct}]"
       action="#{feeProductWizard.startNewWizard()}" propogation="begin" />
      


      Here is the navigation rule from the pages.xml file.
      <page view-id="/fees/*">
       <navigation from-action="#{feeProductWizard.startNewWizard}">
       <redirect view-id="/fees/feeProduct/wizard/step1.xhtml" />
       </navigation>
      </page>
      


      In the application's current state, I can only click on the link once. The wizard is started within the current conversation but it won't start a new conversation and if I attempt to click the link again it tells me the conversation has already been started. Everything else works beautifully though.

      Seam 2.0.0 GA
      Facelets
      JBoss 4.2.2 GA

      Thanks in advance for your help.

      Drew