1
@BalusC가 도와 주며 암호 확인에 문제가 있습니다. here. 그러나 폼에 유효성 검사 코드를 삽입 한 후 컨트롤러 메서드를 호출해도 아무 것도 발생하지 않습니다. 나는 양식을 작성하고 등록하려고 할 때, 아무것도가 lauched 것조차 예외, 발생하지 Register.xhtmlFacesValidator 때문에 ManageBean 메서드가 더 이상 작동하지 않습니까?
<!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>
: 여기 내 JSF 페이지를 이동합니다.
passwod 검사기 (감사 BalusC 동료) :
@FacesValidator("confirmPasswordValidator")
public class ConfirmPasswordValidator implements Validator {
@Override
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
String password = (String) value;
String confirm = (String) component.getAttributes().get("confirm");
if (password == null || confirm == null) {
return; // Just ignore and let required="true" do its job.
}
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"));
}
}
}
내가 정말 여기에서 무슨 일이 일어나고 있는지 모르는,이 문제는 매우 이상한 생각합니다. 감사합니다.
감사합니다. 너 멋지다 –
. 천만에. – BalusC