8 Replies Latest reply on Jun 9, 2006 3:49 PM by David Bernard

    pageflow problems

    Frank Roehler Newbie

      Hi,
      I have an application with several pages, each linked with a next and a previous button without any decision in it. My pageflow is dying within the second page. The flow starts correct with the first site. After pushing the next button the second site is loaded. Then neither the back nor the next button works. The jsp-sites are labeled correctly. I found a similar problem in this forum but this topic didn't help.

      http://www.jboss.com/index.html?module=bb&op=viewtopic&t=79274

      I also tried to expand the numberguess-example with another site after the win.jsp and/or lose.jsp. This also didn't work, the pageflow stops after the second site. There are no errormessages on jboss-console.
      Has anybody an idea?
      I'm using Seam 1.0.0.CR3 with jBoss 4.0.4.GA. Here are the workflow-definiton, the first three .jsp-sites and the JavaBean.

      Thanks,
      Frank

      <?xml version="1.0" encoding="UTF-8"?>
      
      <pageflow-definition
       name="purchaseOrder1">
       <start-page name="PurchaseStartPage">
       <redirect/>
       <transition name="toship" to="ShipTo"></transition>
       </start-page>
       <page name="ShipTo" view-id="/shipTo.jsp">
       <redirect/>
       <transition name="tostart" to="PurchaseStartPage"></transition>
       <transition name="tobill" to="BillTo"></transition>
       </page>
       <page name="BillTo" view-id="/billTo.jsp">
       <redirect/>
       <transition name="topay" to="PaymentMethod"></transition>
       <transition name="toship" to="ShipTo"></transition>
       </page>
       <page name="PaymentMethod" view-id="/paymentMethod.jsp">
       <redirect/>
       <transition name="tobill" to="BillTo"></transition>
       <transition name="toitem" to="Item"></transition>
       </page>
       <page name="Item" view-id="/item.jsp">
       <redirect/>
       <transition name="toreceipt" to="Receipt"></transition>
       <transition name="topay" to="PaymentMethod"></transition>
       </page>
       <page name="Receipt" view-id="/receipt.jsp">
       <redirect/>
       <end-conversation transition="end"/>
       </page>
      </pageflow-definition>


      first site
      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
      <html>
      <head>
      <title>PurchaseOrder1</title>
      </head>
      <body>
      <h1>PurchaseOrder Startpage</h1>
      <f:view>
       <h:form>
       <h:outputText value="Test: #{purchaseOrder1.number}" rendered="true"/>
       <br/>
       <h:commandButton type="submit" value="new Order" action="toship"/>
       </h:form>
      </f:view>
      </body>
      </html>


      second site
      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
      <html>
      <head>
      <title>PurchaseOrder1</title>
      </head>
      <body>
      <h1>shipTo</h1>
      <f:view>
       <h:outputText value="Test: #{purchaseOrder1.number}" rendered="true"/>
       <br/>
       <h:commandButton type="submit" value="previous" action="tostart"/>
       <h:commandButton type="submit" value="next" action="tobill"/>
      </f:view>
      </body>
      </html>


      third site
      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
      <html>
      <head>
      <title>Pageflow1.</title>
      </head>
      <body>
      <h1>billTo</h1>
      <f:view>
       <h:commandButton type="submit" value="next" action="toship"/>
       <h:commandButton type="submit" value="previous" action="topay"/>
      </f:view>
      </body>
      </html>


      JavaBean
      import org.jboss.seam.ScopeType;
      import org.jboss.seam.annotations.Begin;
      import org.jboss.seam.annotations.Create;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Scope;
      
      @Name("purchaseOrder1")
      @Scope(ScopeType.CONVERSATION)
      
      public class PurchaseOrder1
      {
       private boolean stateIt = false ;
       private int number = 100 ;
      
       @Create
       @Begin(pageflow="purchaseOrder1")
       public void begin()
       {
       number = 101 ;
       }
      
       public boolean isTransmit()
       {
       if (stateIt)
       {
       stateIt = false ;
       return true ;
       }
       else
       {
       stateIt = true ;
       return false ;
       }
       }
      
       public int getStateIt()
       {
       if (stateIt)
       return 11 ;
       else
       return 1 ;
       }
      
       public int getNumber()
       {
       return this.number ;
       }
      }


        • 1. Re: pageflow problems
          Gavin King Master

          Your code looks basically good to me. Put the Seam sourcecode in your sourcepath and debug into the SeamNavigationHandler to see what is going on.

          • 2. Re: pageflow problems
            David Bernard Newbie

            Hi,

            From my understand, the pageflow isn't started (no call to begin from an action or link beetween the jsp and the start-page.

            I suggest you to set the view-id attribute of the <start-page> node:

            <start-page name="PurchaseStartPage" view-id="/purchaseStartPage.jsp">


            • 3. Re: pageflow problems
              Gavin King Master

              I think the create method starts the pageflow when the start-page is rendered. So I don't think that is the problem.

              • 4. Re: pageflow problems
                David Bernard Newbie

                You're right (Gavin) about begin of the pageflow,

                In this case, not set view-id on <start-page> will produce a exception when transaction "tostart" form ShipTo will run, because no view are define for PurchaseStartPage.

                An other suggestion : don't use the page/state name to define next/prev button (because if you want to change order of navigation you'll need to change 3 files (minimum) : 2 jsp and the jpdl :
                eg
                in shipTo.jsp :

                <h:commandButton type="submit" value="previous" action="previous"/>
                <h:commandButton type="submit" value="next" action="next"/>
                

                in jpdl
                <page name="ShipTo" view-id="/shipTo.jsp">
                 <redirect/>
                 <transition name="previous" to="PurchaseStartPage"/>
                 <transition name="next" to="BillTo"/>
                 </page>
                


                • 5. Re: pageflow problems
                  Frank Roehler Newbie

                  Gavin,
                  I don't know howto debug in the SeamNavigationHandler. I tried to debug with the Seam-Debugpage over the browser. So I deployed the jboss-seam-debug.jar to the WEB-INF/lib directory in the war-file (Tutorial chapter 1.6.5). I need a SeamDebugPhaseListener to be defined in the faces-config.xml, but I alway get an error from the appserver that the listener isn't found.

                  @dwayneb: which name would you use in .jsp-sites for the buttons to avoid too much changes? E.g. calling a function in a Seamcomponent over the action-attribute?

                  • 6. Re: pageflow problems
                    Frank Roehler Newbie

                    Gavin,
                    I found a tutorial about debugging seam-projects in eclipse. I toggled a breakpoint in the SeamNavigationHandler (in package org.jboss.seam.jsf). It works for the first site. After pushing the next-button on the first jsp-site, the attribues of the Handler are as follows:


                    context=ServlerFacesContextImpl
                    fromAction=null
                    outcome="toship" (correct, this is the navigation-rule for the next site)
                    outcomeIsWithId="false"

                    By pushing a next- or previous-button on the second site nothing happens in the debugger. The application is still running (stop- and pause-button in the debugger is available)



                    • 7. Re: pageflow problems
                      David Bernard Newbie

                      About your problem :

                      My brain was off-line yesterday when I replied. The error in your jsp page is that : your <h:commandButton> tag in page two,... aren't inside a <h:form>.
                      I'm suprised you didn't have exception. I use facalets, when when it found a commandButton or commandLink outside form, it raise an error.

                      About your question :
                      I don't understand it. I only use the two fragment I posted.
                      action's value of commanButton (in jsp) match name's value of transaction in the page.

                      so you could use a jpdl like :

                      <?xml version="1.0" encoding="UTF-8"?>
                      
                      <pageflow-definition
                       name="purchaseOrder1">
                       <start-page name="PurchaseStartPage">
                       <redirect/>
                       <transition name="toship" to="ShipTo"></transition>
                       </start-page>
                       <page name="ShipTo" view-id="/shipTo.jsp">
                       <redirect/>
                       <transition name="back" to="PurchaseStartPage"></transition>
                       <transition name="next" to="BillTo"></transition>
                       </page>
                       <page name="BillTo" view-id="/billTo.jsp">
                       <redirect/>
                       <transition name="next" to="PaymentMethod"></transition>
                       <transition name="back" to="ShipTo"></transition>
                       </page>
                       <page name="PaymentMethod" view-id="/paymentMethod.jsp">
                       <redirect/>
                       <transition name="back" to="BillTo"></transition>
                       <transition name="next" to="Item"></transition>
                       </page>
                       <page name="Item" view-id="/item.jsp">
                       <redirect/>
                       <transition name="next" to="Receipt"></transition>
                       <transition name="back" to="PaymentMethod"></transition>
                       </page>
                       <page name="Receipt" view-id="/receipt.jsp">
                       <redirect/>
                       <end-conversation transition="end"/>
                       </page>
                      </pageflow-definition>
                      


                      and build you jsp page like :
                      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
                      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
                      <html>
                      <head>
                      <title>PurchaseOrder1</title>
                      </head>
                      <body>
                      <h1>shipTo</h1>
                      <f:view>
                      <h:form>
                       <h:outputText value="Test: #{purchaseOrder1.number}" rendered="true"/>
                      ...
                       <br/>
                       <h:commandButton type="submit" value="previous" action="back"/>
                       <h:commandButton type="submit" value="next" action="next"/>
                      </h:form>
                      </f:view>
                      </body>
                      </html>
                      




                      • 8. Re: pageflow problems
                        David Bernard Newbie

                        I forgot to add the view-id of start-page (need to allow back from ShipTo:

                        <?xml version="1.0" encoding="UTF-8"?>
                        
                        <pageflow-definition
                         name="purchaseOrder1">
                         <start-page name="PurchaseStartPage" view-id="/purchase.jsp">
                         <redirect/>
                         <transition name="toship" to="ShipTo"></transition>
                         </start-page>
                         <page name="ShipTo" view-id="/shipTo.jsp">
                         <redirect/>
                         <transition name="back" to="PurchaseStartPage"></transition>
                         <transition name="next" to="BillTo"></transition>
                         </page>
                         <page name="BillTo" view-id="/billTo.jsp">
                         <redirect/>
                         <transition name="next" to="PaymentMethod"></transition>
                         <transition name="back" to="ShipTo"></transition>
                         </page>
                         <page name="PaymentMethod" view-id="/paymentMethod.jsp">
                         <redirect/>
                         <transition name="back" to="BillTo"></transition>
                         <transition name="next" to="Item"></transition>
                         </page>
                         <page name="Item" view-id="/item.jsp">
                         <redirect/>
                         <transition name="next" to="Receipt"></transition>
                         <transition name="back" to="PaymentMethod"></transition>
                         </page>
                         <page name="Receipt" view-id="/receipt.jsp">
                         <redirect/>
                         <end-conversation transition="end"/>
                         </page>
                        </pageflow-definition>