I have a class implementing Validator so i can define some custom validation rules for a property:
@Override
public void validate(FacesContext fc, UIComponent uic, Object obj) throws ValidatorException {
Date date = (Date)obj;
if(date == null) {
FacesMessage msg = new FacesMessage("no value");
throw new ValidatorException(msg);
}
}
This custom error is not displayed when i submit an empty value:
<h:column>
<h:inputText value="#{bean.date}" id="date">
<f:facet name="date">Date</f:facet>
<f:convertDateTime pattern="d.M.yyyy"/>
<f:validator validatorId="dateValidator"/>
</h:inputText>
<h:message for="date" style="color:red"/>
</h:column>
So how can i validate if the date-field was even submitted(if it is not null)