6 Replies Latest reply on Dec 20, 2008 7:52 AM by Veli AKÇAKAYA

    Check two passwords via CustomValidation

    Veli AKÇAKAYA Newbie

      Hi, i'm new in JSF.

      i have design a registration form. I want to check that are passwords equal. i wrote a custom validation method for this reason in my bean class. it is;

      public void passwordValidate(FacesContext arg0, UIComponent arg1, Object val) throws ValidatorException {
      System.out.println("this.getPassword2()=" + val.toString());
      System.out.println("this.getPassword()=" + this.getPassword());
      if(!this.getPassword2().equals(this.getPassword())) {
      throw new ValidatorException(new FacesMessage("Passwords don't match"));

      And i use it in the form this type;

      <a4j:form id="registerForm">
      <h:outputText value="#{msg.password}" />
      <h:inputSecret id="RegPasswd" value="#{regForm.password}" required="true" autocomplete="false" />
      <rich:message for="RegPasswd"/>

      <h:outputText value="#{msg.password_again}" />
      <h:inputSecret id="RegPasswd2" value="#{regForm.password2}" size="14" maxlength="16" required="true" validator="#{regForm.passwordValidate}">
      <a4j:support ajaxSingle="true" event="onblur"></a4j:support>
      <rich:message for="RegPasswd2"></rich:message>
      <a4j:commandButton value="#{msg.login}" action="#{regForm.doSimpleRegister}" />

      But i can't get first password inputSecret value via this.getPassword() method. getPassword() is in the same Bean file. How can i get first password and check them.