5 Replies Latest reply on May 19, 2009 12:52 PM by tazz786

    Initiate a PageFlow via a URL which is not a page in the PageFlow

    rgustav

      I'm trying to figure out how to launch a pageflow using a URL which routes directly into the <start-state> of the pageflow?


      Specifically, the pageflow does does not have a pre-determined initial view, and must make a decision to decide which page is appropriate.


      What would the pages.xml entry look like? 


      <page ??? >
         <begin-conversation pageflow="thepageflow"/>
      </page>
      



      Something that looks like /ThePageFlow (w/ or w/o .seam on end) would be ideal.  Something like /ImpossibleToDetermineApriori.xhtml is totally wrong.


      The Seam examples use pageflows and <start-state>, but not in this fashion.

        • 1. Re: Initiate a PageFlow via a URL which is not a page in the PageFlow
          rgustav

          Ok, I figured this out, hopefully someone else will find this useful.


          I can access with /MyPageFlow.seam using something like:


          <page view-id="/MyPageFlow.xhtml" action="#{MyPageFlowAction.init}">
               <begin-conversation pageflow="MyPageFlow"/>
          </page>
          



          Note: MyPageFlow.xhtml is a NON-EXISTANT file, this is what threw me for a loop, I hadn't realized this was even possible.


          Given a PageFlowDefinition snippit like:


          <start-state name="Start">
               <transition name="init1" to="Page1"/>
               <transition name="init2" to="Page2"/>
          </start-state>
          



          And an action class like:


          @Name("MyPageFlowAction")
          public class MyPageFlowAction{
               public String init() {
                    if (condition1) {
                         return "init1";
                    } else {
                         return "init2";
                    }
               }
          }
          



          Figuring out 'condition' is up to you. :)  I still need to work on getting contextual parameters passed to the init() method, but that's a separate problem.

          • 2. Re: Initiate a PageFlow via a URL which is not a page in the PageFlow

            Hi Ryan,


            Interesting tip, I've book marked this for when I will need it!! Did you ever come across the need for page params in page flows and did you solve it or work around it?


            Troy

            • 3. Re: Initiate a PageFlow via a URL which is not a page in the PageFlow
              andre1001

              Ryan,


              I've got the same behavior without your workaround.


              This is the URL sent in e-mail:
                   


              http://localhost:8080/menu/registroUsuario/UsuarioEdit.seam?conversationPropagation=begin.newuser&amp;codigo=#{codigoConfirmacao}&amp;taskId=#{taskInstance.id}




              This is the newuser.jpdl.xml code:



              <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.1.xsd"
                    name="newuser">
                     
                  <start-page name="usuario" view-id="/registroUsuario/UsuarioEdit.xhtml" redirect="true">
                       <action expression="#{registroUsuario.confirmar}"></action>
                       <transition name="inicio" to="inicio"></transition>
                   </start-page>
                  
                  <page name="inicio" view-id="/outros/inicio.xhtml"></page>
                 
              </pageflow-definition>





              There is no need for a UsuarioEdit.page.xml file.


              Thasks. I've started with your tip.

              • 4. Re: Initiate a PageFlow via a URL which is not a page in the PageFlow
                andre1001

                By the way. The only way to choose the first page to show in pageflow is as suggested by Ryan.


                I was not able to use something like a direct method invocation.




                • 5. Re: Initiate a PageFlow via a URL which is not a page in the PageFlow
                  tazz786

                  Hi Ryan


                  I am trying to create an application whereby , the user would enter the url, like
                  www.ab.com/xyz...where xyz can be anything...I would then have to get the value...i.e. xyz, and then do logic and forward to the necessary pages... I have seen you solution for the above..Would your solution work for my situation, and I am new to seam, so not sure where a pageflow definition would go..I only have a pages.xml and a web.xml