1 Reply Latest reply on Feb 11, 2009 11:47 AM by karthicprabhu

    Faces Messages Not displayed on Login Page. How to redirect the same page when login failed?

    karthicprabhu
      Here I have my pages.xml as,

      <page view-id="/login.xhtml">
         
              <navigation>
                  <rule if="#{identity.loggedIn}">
                      <redirect view-id="/sample/index.xhtml"/>
                  </rule>              
              </navigation>
             
          </page>

          <page view-id="/sample/index.xhtml" action="#{dashboard.getDashboardReports}"/>
         
          <page view-id="*">
         
              <navigation>
                  <rule if-outcome="forgotpassword">
                      <redirect view-id="/getpassword.xhtml"/>
                  </rule>
                  <rule if-outcome="gotologin">
                      <redirect view-id="/login.xhtml"/>
                  </rule>
               </navigation>

               <navigation from-action="#{identity.login}">
                      <rule if="#{not identity.loggedIn}">
                      <redirect view-id="/login.xhtml"/>
                  </rule>      
              </navigation>
                     
          </page>

      --------------------------------------------------------------

      On Server It shows:

      10:34:51,574  INFO SessionTimeoutFilter:72 - inside sessiontimeoutfilter dofilter method
      10:34:51,574  INFO SessionTimeoutFilter:94 - Request Path is /mtc/login.seam
      Feb 11, 2009 10:34:51 AM com.sun.faces.lifecycle.RenderResponsePhase execute
      INFO: WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
      sourceId=null[severity=(INFO 0), summary=(Login failed), detail=(Login failed)]
      sourceId=null[severity=(INFO 0), summary=(Invalid Username/Password), detail=(Invalid Username/Password)]

      Here, the issue is the messages on the login.xhtml pages is not displayed, it just redirect to itself.


      My login.xhtml file is:


      <div id="wrap" class="clearfix">
              <f:view contentType="text/html">
                      <f:loadBundle basename="messages" var="messages" />              
                      <div id="loginarea" style="display: block;">
                      <h:form id="login_form">
                          <h:message for="login_form" styleClass="error" />

                          <h:outputLabel for="username" value="Login" />
                          <h:inputText id="username" value="#{identity.username}" tabindex="1" required="true" size="30" requiredMessage="#{messages.username}" >
                          </h:inputText>
                          <h:message id="usernameError" for="username" styleClass="error" />

                          <h:outputLabel for="password" value="Password" styleClass="standard" />
                          <h:inputSecret id="password" value="#{identity.password}" required="true" maxlength="20" requiredMessage="#{messages.password}" >                                    
                          </h:inputSecret>                   
                          <h:message id="passwordError" for="password" styleClass="error" /><hr />                               

                          <h:commandButton id="loginButton" value="Login &#187;"  action="#{identity.login}"/>                     
                          <f:verbatim>&amp;nbsp;&amp;nbsp;</f:verbatim>
                          <h:commandButton id="pwdButton" value="Forgot Password &#187;" action="forgotpassword" immediate="true"/>
                      </h:form>
                      </div>                   
              </f:view>
          </div>


      Any one suggest me How to redirect to login.xhtml page itself when login failed. ie., if not identity.loggedIn

      Note: I can get the messgaes displayed on the getpassword.xhtml when forgotpassword button is clicked to retrieve password info. 
        • 1. Re: Faces Messages Not displayed on Login Page. How to redirect the same page when login failed?
          karthicprabhu

          Here I have my pages.xml as,

          <page view-id="/login.xhtml">
             
                  <navigation>
                      <rule if="#{identity.loggedIn}">
                          <redirect view-id="/sample/index.xhtml"/>
                      </rule>              
                  </navigation>
                 
              </page>

              <page view-id="/sample/index.xhtml" action="#{dashboard.getDashboardReports}"/>
             
              <page view-id="*">
             
                  <navigation>
                      <rule if-outcome="forgotpassword">
                          <redirect view-id="/getpassword.xhtml"/>
                      </rule>
                      <rule if-outcome="gotologin">
                          <redirect view-id="/login.xhtml"/>
                      </rule>
                   </navigation>

                   <navigation from-action="#{identity.login}">
                          <rule if="#{not identity.loggedIn}">
                          <redirect view-id="/login.xhtml"/>
                      </rule>      
                  </navigation>
                         
              </page>

          --------------------------------------------------------------

          On Server It shows:

          10:34:51,574  INFO SessionTimeoutFilter:72 - inside sessiontimeoutfilter dofilter method
          10:34:51,574  INFO SessionTimeoutFilter:94 - Request Path is /project/login.seam
          Feb 11, 2009 10:34:51 AM com.sun.faces.lifecycle.RenderResponsePhase execute
          INFO: WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
          sourceId=null[severity=(INFO 0), summary=(Login failed), detail=(Login failed)]
          sourceId=null[severity=(INFO 0), summary=(Invalid Username/Password), detail=(Invalid Username/Password)]

          Here, the issue is the messages on the login.xhtml pages is not displayed, it just redirect to itself.


          My login.xhtml file is:


          <div id="wrap" class="clearfix">
                  <f:view contentType="text/html">
                          <f:loadBundle basename="messages" var="messages" />              
                          <div id="loginarea" style="display: block;">
                          <h:form id="login_form">
                              <h:message for="login_form" styleClass="error" />

                              <h:outputLabel for="username" value="Login" />
                              <h:inputText id="username" value="#{identity.username}" tabindex="1" required="true" size="30" requiredMessage="#{messages.username}" >
                              </h:inputText>
                              <h:message id="usernameError" for="username" styleClass="error" />

                              <h:outputLabel for="password" value="Password" styleClass="standard" />
                              <h:inputSecret id="password" value="#{identity.password}" required="true" maxlength="20" requiredMessage="#{messages.password}" >                                    
                              </h:inputSecret>                   
                              <h:message id="passwordError" for="password" styleClass="error" /><hr />                               

                              <h:commandButton id="loginButton" value="Login &#187;"  action="#{identity.login}"/>                     
                              <f:verbatim>&amp;nbsp;&amp;nbsp;</f:verbatim>
                              <h:commandButton id="pwdButton" value="Forgot Password &#187;" action="forgotpassword" immediate="true"/>
                          </h:form>
                          </div>                   
                  </f:view>
              </div>


          Any one suggest me How to redirect to login.xhtml page itself when login failed. ie., if not identity.loggedIn

          Note: I can get the messgaes displayed on the getpassword.xhtml when forgotpassword button is clicked to retrieve password info. 


          Click HELP for text formatting instructions. Then edit this text and check the preview.