Java ManageBean方法don';因为FacesValidator,它不再工作了?

Java ManageBean方法don';因为FacesValidator,它不再工作了?,java,validation,jsf,jsf-2,Java,Validation,Jsf,Jsf 2,我在密码验证方面遇到了一些问题,@BalusC帮了我的忙。 但是在表单中插入验证代码之后,当我调用控制器方法时,什么也没有发生。 下面是我的JSF页面: Register.xhtml <!DOCTYPE html> <html lang="pt-br" xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.c

我在密码验证方面遇到了一些问题,@BalusC帮了我的忙。 但是在表单中插入验证代码之后,当我调用控制器方法时,什么也没有发生。 下面是我的JSF页面: Register.xhtml

<!DOCTYPE html>
<html lang="pt-br"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich">

    <h:head>
        <title>TITLE</title>
    </h:head>

    <h:body>
         <h:form id="form">
            <h:panelGrid columns="3" >

                <h:outputLabel for="name"   value="Nome:" />
                <h:inputText   id="name"    value="#{register.person.name}"  >  
                    <f:ajax    event="blur" listener="#{register.validateName}" render="m_name" />
                </h:inputText>
                <rich:message  id="m_name"  for="name"  ajaxRendered="false"/>

                // some fields ..                    

                <h:outputLabel for="password" value="Password" />
                <h:inputSecret id="password" value="#{register.user.password}">
                    <f:validator validatorId="confirmPasswordValidator" />
                    <f:attribute name="confirm" value="#{confirmPassword.submittedValue}" />
                    <f:ajax event="blur" execute="password confirm" render="m_password" />
                </h:inputSecret>
                <rich:message id="m_password" for="password" />

                <h:outputLabel for="confirm" value="Senha (novamente):" />
                <h:inputSecret id="confirm" binding="#{confirmPassword}" >
                    <f:ajax event="blur" execute="password confirm" render="m_password m_confirm" />
                </h:inputSecret>
                <rich:message id="m_confirm" for="confirm" />

                <h:commandButton value="Register" action="#{register.registerPerson}" >
                    <f:ajax execute="@form" render="@form" />
                </h:commandButton>

                <h:outputText value="#{register.recordStatus}" id="out"  />
                <a4j:status>
                    <f:facet name="start">
                        <h:graphicImage name="loader.gif" library="image"/>
                    </f:facet>
                </a4j:status>    
        </h:panelGrid>
    </h:form>
    </h:body>
</html>
我觉得这个问题很奇怪,我真的不知道这里发生了什么。
谢谢大家。

你们在一场成功的比赛中抛出了一个
验证异常

if (!password.equals(confirm)) {
    throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, null, "password not equal"));
} else {
    throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_INFO, null, "ok"));
}
这会导致JSF阻止表单提交。严重程度无关紧要。验证器异常是验证器异常。它表示失效

而不是使用

if (!password.equals(confirm)) {
    throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, null, "password not equal"));
} else {
    throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_INFO, null, "ok"));
}
if (!password.equals(confirm)) {
    throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, null, "password not equal"));
} else {
    context.addMessage(component.getClientId(), new FacesMessage(FacesMessage.SEVERITY_INFO, null, "ok"));
}