3 Replies Latest reply on Jun 12, 2007 7:46 PM by jazir1979

    h:messages for Authenticator

      Hello all,

      I am trying to display a customized error message should the authenticate method failed to authenticate a user. I.e.

      @Name("authenticator")
      public class Authenticator {
       @In
       private FacesMessages facesMessages;
      ...
       public boolean authenticate() {
       try {
      ...
       } catch (AuthenticationException e) {
       facesMessages.add("#{res['login.failed.msg']}");
       return false;
       }


      However, this message is not showing when the authenticate method failed. The login.xml page is coded as followed:

      <h:panelGrid rendered="#{! empty facesContext.maximumSeverity}">
       <h:messages for="dialog" styleClass="message" />
      </h:panelGrid>


      Any idea?

      Thanks for your help.
      -tony

        • 1. Re: h:messages for Authenticator
          christian.bauer

          Well, you add() a global message but only display messages that have been added for="dialog" component.

          • 2. Re: h:messages for Authenticator

            You're right.

            However, after I've added a panel with id for the message, it's still not displayed.

            <a4j:outputPanel id="loginPanel">
             <h:panelGrid rendered="#{! empty facesContext.maximumSeverity}">
             <h:messages for="loginPanel" styleClass="message" />
             </h:panelGrid>


            Is there anything that I could have erred that caused this message to be dropped after the Authenticator.authenticate() method called?

            Thanks

            • 3. Re: h:messages for Authenticator
              jazir1979


              But it's still a global message, not "for" your loginPanel. Either remove the "for" and display your global messages, or use facesMessage.addToControl() in the code.

              "tonylmai" wrote:
              You're right.

              However, after I've added a panel with id for the message, it's still not displayed.

              <a4j:outputPanel id="loginPanel">
               <h:panelGrid rendered="#{! empty facesContext.maximumSeverity}">
               <h:messages for="loginPanel" styleClass="message" />
               </h:panelGrid>


              Is there anything that I could have erred that caused this message to be dropped after the Authenticator.authenticate() method called?

              Thanks