
Untitled
By: a guest on
May 7th, 2012 | syntax:
None | size: 0.58 KB | hits: 30 | expires: Never
how to invoke JSF Validator on keyup event?
<h:inputText id="foo" value="#{bean.foo}">
<f:ajax event="keyup" execute="@this" render="fooMessage" />
<f:validator validatorId="fooValidator" />
</h:inputText>
<h:message id="fooMessage" for="foo" />
@FacesValidator("fooValidator")
public class FooValidator implements Validator {
@Override
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
// ...
if (invalid) {
throw new ValidatorException(new FacesMessage("Fail!"));
}
}
}