Do faces-config.xml:
<validator> <validator-id>myValidator</validator-id> <validator-class>cz.softeu.test.MyValidator</validator-class> </validator>
V šabloně:
<h:inputText ...> <f:validator validatorId="myValidator"/> </h:inputText>
public class MyValidator implements Validator { public void validate(FacesContext facesContext, UIComponent uiComp, Object value) throws ValidatorException { FacesMessage fm = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Always fail", "This validator always fails."); throw new ValidatorException(fm); } }