2 Replies Latest reply on May 11, 2007 1:41 PM by Glenn Marcus

    Conditional navigation in pages.xml

    Glenn Marcus Newbie

      I am trying to use navigation in pages.xml.

       <page view-id="/emailvalidate.xhtml" action="#{account.validateEmail}">
       <param name="tk" value="#{token.hash}"/>
       <navigation from-action="#{account.validateEmail}">
       <rule if-outcome="success">
       <render view-id="/login.xhtml"/>
       </rule>
       </navigation>
       </page>
      


      if the action returns "success", seam renders /login.xhtml

      This is what I expected.

      What I would like to do, is if the outcome is null, render /validate.xhtml

      I tried this:

       <page view-id="/emailvalidate.xhtml" action="#{account.validateEmail}">
       <param name="tk" value="#{token.hash}"/>
       <param name="src" value="email"/>
       <navigation from-action="#{account.validateEmail}">
       <rule if-outcome="success">
       <render view-id="/login.xhtml"/>
       </rule>
       <rule>
       <render view-id="/validate.xhtml"/>
       </rule>
       </navigation>
       </page>
      


      For any outcome other than "success", I expected /validate.xhtml to be rendered, but instead, seam renders the original view-id which is /emailvalidate.xhtml

      How can I render one page for a specific outcome from an action, and a different page for any other outcome including null?

      Glenn

        • 1. Re: Conditional navigation in pages.xml
          Christian Bauer Master

          You can't, "null" outcome means re-render.

          • 2. Re: Conditional navigation in pages.xml
            Glenn Marcus Newbie

             

            "christian.bauer@jboss.com" wrote:
            You can't, "null" outcome means re-render.


            I was hoping that I could avoid having to put additional outcomes or view logic inside my business layer call to account.validateEmail() (which is a SFSB)

            It made sense to me that I should be able to redirect to a view in case of null. Even the Seam Reference Documentation shows an example of this in Section 5.1.1.2:

            If you want to perform navigation when a null outcome occurs, use the following form instead:

            <page view-id="/editDocument.xhtml">
            
             <navigation from-action="#{documentEditor.update}">
             <render view-id="/viewDocument.xhtml"/>
             </navigation>
            
            </page>
            




            I thought you can define multiple rules with a naviagation element. How do I specify multiple rules in this case to go to one view on outcome of "success" and another view for anything else?


            Glenn