我根据JSF 2规范注册了一个Validator:
@FacesValidator(value = "emailValidator")
public class EmailValidator implements Validator {..}
用法:
<h:inputText value=#{bean.email}>
<f:validator id="emailValidator" />
</h:inputText>
我得到了这个例外:
javax.servlet.ServletException: /contact.xhtml @21,130 <f:validator> A validator id was not specified. Typically the validator id is set in the constructor ValidateHandler(ValidatorConfig)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)
org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)
myapp.FilterLogout.doFilter(FilterLogout.java:83)
这是一个错误吗?
答案 0 :(得分:3)
试试这个
@FacesValidator(value="emailValidator")
public class EmailValidator implements Validator {
@override
public void validate(FacesContext context, UIComponent component,
Object value) throws ValidatorException {
}
}
在xhtml中,你有
<h:inputText value=#{bean.email}>
<f:validator validatorId="emailValidator" />
</h:inputText>