4 Replies Latest reply on Mar 16, 2008 7:01 PM by Raj Tiwari

    Basic Seam navigation issue

    Raj Tiwari Newbie

      I have a three step login process:


      1. Pre-login: user enters an ID


      2. login continuation: The server munches on ID, sends user to a login-continue page


      3. login completion: user enters info on login-continue, submits to server and if all goes well, user is logged in.


      This is implemented by a SFSB and three view pages (actually four since login continuation has two versions based on the outcome of pre-login).


      The pre-login view has something to this effect:


      <h:inputText id="userId" value="#{Login.userId}"/>
      <h:commandButton id="loginButton" value=" Begin Login!" action="#{Login.preLogin}"/>
      



      The preLogin() method on the Login Stateful bean works with userId and returns a string that tells which version of the login continuation view to present:


      @Begin(join=true)
      public String preLogin()
      {
      ...
        if(version == 1)
        {
          return "v1";
        }
        else
        {
          return "v2";
        }
      



      I have the following in my pages.xml:


      <page view-id="/preLogin.xhtml">
          <navigation from-action="#{Login.preLogin}">
              <rule if-outcome="v1">
                  <redirect view-id="/loginContinueV1.xhtml"/>
              </rule>
              <rule if-outcome="v2">
                  <redirect view-id="/loginContinueV2.xhtml"/>
              </rule>
          </navigation>
      </page>
      


      No matter what I do, when I click the Begin Login! button on the pre login page, I end up back on that page with no redirection to login continuation page.


      I am sure I am making some very obvious beginner mistake. Can any of the experts point it out to me?

        • 1. Re: Basic Seam navigation issue
          Nicklas Karlsson Master

          Could you show your complete pages.xhtml. So that you don't e.g have a login-view="/preLogin.xhtml" that throws you back since you haven't relly done the login yet?

          • 2. Re: Basic Seam navigation issue
            Raj Tiwari Newbie

            Nicklas,
            Many thanks for the prompt response. Here is the complete 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"
            
                   no-conversation-view-id="/home.xhtml"
                   login-view-id="/preLogin.xhtml">
            
                <page view-id="*" login-required="true">
                    <navigation>
                        <rule if-outcome="home">
                            <redirect view-id="/home.xhtml"/>
                        </rule>
                    </navigation>
                </page>
                
                <page view-id="/preLogin.xhtml">
                    <navigation from-action="#{Login.preLogin}">
                        <rule if-outcome="v1">
                            <redirect view-id="/loginContinueV1.xhtml"/>
                        </rule>
                        <rule if-outcome="v2">
                            <redirect view-id="/loginContinueV2.xhtml"/>
                        </rule>
                    </navigation>
                </page>
                
            <!-- TBD nagivation from loginContinue to loginComplete -->
            
                <exception class="org.jboss.seam.framework.EntityNotFoundException">
                    <redirect view-id="/error.xhtml">
                        <message>Not found</message>
                    </redirect>
                </exception>
                
                <exception class="javax.persistence.EntityNotFoundException">
                    <redirect view-id="/error.xhtml">
                        <message>Not found</message>
                    </redirect>
                </exception>
                
                <exception class="javax.persistence.OptimisticLockException">
                    <end-conversation/>
                    <redirect view-id="/error.xhtml">
                        <message>Another user changed the same data, please try again</message>
                    </redirect>
                </exception>
                
                <exception class="org.jboss.seam.security.AuthorizationException">
                    <redirect view-id="/error.xhtml">
                        <message>You don't have permission to do this</message>
                    </redirect>
                </exception>
                
                <exception class="org.jboss.seam.security.NotLoggedInException">
                    <redirect view-id="/login.xhtml">
                        <message>Please log in first</message>
                    </redirect>
                </exception>
                
                <exception class="javax.faces.application.ViewExpiredException">
                    <redirect view-id="/error.xhtml">
                        <message>Your session has timed out, please try again</message>
                    </redirect>
                </exception>
                 
                <exception>
                    <redirect view-id="/error.xhtml">
                        <message>Unexpected error, please try again</message>
                    </redirect>
                </exception>
                
            </pages>
            
            

            • 3. Re: Basic Seam navigation issue
              Nicklas Karlsson Master

              Try removing the login-view-id and go to the login page manually (/preLogin.seam) and see if the naviation works then. It might be as I guessed in my previous post that you get bounced back due to that.


              Off to sleep, midnight soon.

              • 4. Re: Basic Seam navigation issue
                Raj Tiwari Newbie

                Nicklas,


                I'll have to do a better study of pages.xml. Seam is a beautiful framework and I have enjoyed using it so far. However, page navigation has got to be one of the murkiest features. Extremely difficult for a newcomer to grasp.


                I think the biggest problem is the lack of a glossary. For example: What is the meaning of an action listener? What is an outcome? Does it have to be a string? Does navigate from action apply to the page I am navigating from or the page I am at? How do I create a default page for a directory so I don't have to give out a foo.seam URL?


                Most documentation focuses on differences from JSF rather than describing the framework at hand.


                Thanks for bearing with the rant.


                -Raj