3 Replies Latest reply on Jul 17, 2008 5:27 AM by Nalina R

    Unable to navigate using pageflow defination

    Nalina R Newbie

      Hi,
        I am trying to implement number guess flow using seam pageflow, but from numberguess.jsp i am unable to navigate to next page. I am not getting any errors. Could anyone please tell me how to fis this issue

        • 1. Re: Unable to navigate using pageflow defination
          System Administrator Expert

          Be more specific about your test case and post your code.

          • 2. Re: Unable to navigate using pageflow defination
            Nalina R Newbie
            Hi Please find the code we are using. Basicaly clicking on guess button doesnot navigate to the win.jsp. When we click on the guess button, the guess() method is not being invoked.



            Pages.xml
            <?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.0.xsd">



              <page view-id="/numberGuess.jsp">

                    <begin-conversation join="true" pageflow="numberguess"/>

               </page>



            </pages>  



            2. component.xml

            <component name="org.jboss.seam.bpm.jbpm" >

                             <property name="pageflow-definitions">

                  <value>pageflow.jpdl.xml</value>

                  </property>

            </component>



            3. We are deploying our application as EAR file so the pageflow.jpdl.xml is in numberguess.ear.



            4. NumberGuess. java



            package com.number;



            import java.io.Serializable;

            import java.util.Random;



            import org.jboss.seam.ScopeType;

            import org.jboss.seam.annotations.Create;

            import org.jboss.seam.annotations.Name;

            import org.jboss.seam.annotations.Scope;



            @Name("numberGuess")

            @Scope(ScopeType.CONVERSATION)

            public class NumberGuess implements Serializable{

              

               private int randomNumber;

               private Integer currentGuess;

               private int biggest;

               private int smallest;

               private int guessCount;

               private int maxGuesses;

               private boolean cheated;

              

               @Create

               public void begin()

               {

                  randomNumber = new Random().nextInt(100);

                  guessCount = 0;

                  biggest = 100;

                  smallest = 1;

               }

              

               public void setCurrentGuess(Integer guess)

               {

                  this.currentGuess = guess;

               }

              

               public Integer getCurrentGuess()

               {

                  return currentGuess;

               }

              

               public void guess()

               {

                  if (currentGuess>randomNumber)

                  {

                     biggest = currentGuess - 1;

                  }

                  if (currentGuess<randomNumber)

                  {

                     smallest = currentGuess + 1;

                  }

                  guessCount ++;

               }

              

               public boolean isCorrectGuess()

               {

                  return currentGuess==randomNumber;

               }

              

               public int getBiggest()

               {

                  return biggest;

               }

              

               public int getSmallest()

               {

                  return smallest;

               }

              

               public int getGuessCount()

               {

                  return guessCount;

               }

              

               public boolean isLastGuess()

               {

                  return guessCount==maxGuesses;

               }



               public int getRemainingGuesses() {

                  return maxGuesses-guessCount;

               }



               public void setMaxGuesses(int maxGuesses) {

                  this.maxGuesses = maxGuesses;

               }



               public int getMaxGuesses() {

                  return maxGuesses;

               }



               public int getRandomNumber() {

                  return randomNumber;

               }



               public void cheated()

               {

                  cheated = true;

               }

              

               public boolean isCheat() {

                  return cheated;

               }

              

            }



            5. pages.jpdl.xml



            <pageflow-definition

                  xmlns="http://jboss.com/products/seam/pageflow"

                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                xsi:schemaLocation=

                      "http://jboss.com/products/seam/pageflow http://jboss.com/products/seam/pageflow-2.0.xsd"

                  name="numberGuess">

              

            <start-page name="displayGuess" view-id="/numberGuess.jsp">

                  <redirect/>

                  <transition name="guess" to="evaluateGuess">

                     <action expression="#{numberGuess.guess}"/>

                  </transition>

                  <transition name="giveup" to="giveup"/>

                  <transition name="cheat" to="cheat"/>

            </start-page>



             

              <decision name="evaluateGuess" expression="#{numberGuess.correctGuess}">

                 <transition name="true" to="win"/>

                 <transition name="false" to="evaluateRemainingGuesses"/>

              </decision>

             

              <decision name="evaluateRemainingGuesses" expression="#{numberGuess.lastGuess}">

                 <transition name="true" to="lose"/>

                 <transition name="false" to="displayGuess"/>

              </decision>

             

              <page name="win" view-id="/win.jspx" redirect="true">

                 <end-conversation />

              </page>

             

              <page name="lose" view-id="/lose.jspx" redirect="true">

                 <end-conversation />

              </page>

              

            </pageflow-definition>



            6. web.xml





              <!-- Seam -->

               

                <listener>

                    <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>

                </listener>

               

                <servlet>

                    <servlet-name>Seam Resource Servlet</servlet-name>

                    <servlet-class>org.jboss.seam.servlet.ResourceServlet</servlet-class>

                </servlet>



                <servlet-mapping>

                    <servlet-name>Seam Resource Servlet</servlet-name>

                    <url-pattern>/seam/resource/*</url-pattern>

                </servlet-mapping>



                <filter>

                    <filter-name>Seam Filter</filter-name>

                    <filter-class>org.jboss.seam.web.SeamFilter</filter-class>

                </filter>



                <filter-mapping>

                    <filter-name>Seam Filter</filter-name>

                    <url-pattern>/*</url-pattern>

                </filter-mapping>



                <!-- MyFaces -->

                <!--

                <listener>

                    <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>

                </listener>

                -->

               

                <context-param>

                    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>

                    <param-value>client</param-value>

                </context-param>

               

                <context-param>

                    <param-name>facelets.DEVELOPMENT</param-name>

                    <param-value>true</param-value>

                </context-param>



                <context-param>

                    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>

                    <param-value>.xhtml</param-value>

                </context-param>



                <servlet>

                  <servlet-name>Faces Servlet</servlet-name>

                  <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>

                  <load-on-startup>1</load-on-startup>

                </servlet>



                <!-- Faces Servlet Mapping -->

                <servlet-mapping>

                  <servlet-name>Faces Servlet</servlet-name>

                  <url-pattern>*.seam</url-pattern>

                </servlet-mapping>



            Note: Under WEB-INF : componet.xml, pages.xml and web.xml are there.



            pages.jpdl.xml is outside the WEB-INF i.e. where seam.properties is put.



            Problem: When we click the <h:commandButton value="Guess" action="guess"/>

                   on numberGuess.jsp, the navigation to the next page is not happening.



            We are using seam.2.0.0 and jboss server is 4.2.2.GA.

            • 3. Re: Unable to navigate using pageflow defination
              Nalina R Newbie

              Hi COuld any one please let me know what is wrong or atleast give a binary for numberguess example with pageflow for seam.2.0.0 or a higher version. I have been workign on this since three weeks without wny success. Please help me I need it urgently..