3 Replies Latest reply on Feb 25, 2011 10:09 AM by Ilya Shaikovsky

    RF4 M6 - Object Validation only works with h:commandButton, not a4j:commandButton

    Flávio Henrique Newbie

      When I use a4j:commandButton, I can´t get Object Validation work, but, if I change it to h:commandButton, works fine. What I am doing wrong?


      The Bean


      package teste;


      import java.io.Serializable;

      import javax.faces.application.FacesMessage;

      import javax.faces.bean.ManagedBean;

      import javax.faces.bean.ViewScoped;

      import javax.faces.context.FacesContext;

      import javax.validation.constraints.AssertTrue;

      import org.hibernate.validator.constraints.Length;




      public class ValidatorMB implements Serializable {


                private static final long serialVersionUID = 1L;


                @Length(min = 8, max = 12)

                private String senha;


                @Length(min = 8, max = 12)

                private String confirmar;


                @AssertTrue(message = "Senha não confirma!")

                public boolean isPasswordsEquals() {

                          return senha.equals(confirmar);



                public String getSenha() {

                          return senha;



                public void setSenha(String senha) {

                          this.senha = senha;



                public String getConfirmar() {

                          return confirmar;



                public void setConfirmar(String confirmar) {

                          this.confirmar = confirmar;



                public String gravar() {




                                              new FacesMessage(FacesMessage.SEVERITY_INFO,

                                                                  "Succesfully changed!", "Succesfully changed!"));

                          return null;




      The pag


      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

      <html xmlns="http://www.w3.org/1999/xhtml"










                <rich:graphValidator value="#{validatorMB}">


                                    <f:facet name="header">


                                                        <h:outputText value="User information" />




                                    <h:panelGrid columns="3">

                                              <h:outputText value="Name:" />

                                              <h:inputText id="senha" label="Senha" value="#{validatorMB.senha}">

                                                        <rich:validator />


                                              <rich:message for="senha" />

                                              <h:outputText value="Confirmar" />

                                              <h:inputText id="confirmar" label="Confirmar" value="#{validatorMB.confirmar}">

                                                        <rich:validator />


                                              <rich:message for="confirmar" />


                                    <a4j:commandButton value="Ok" action="#{validatorMB.gravar}"/>