I have 2 date fields, the second can not be earlier, but I can not validate.
Each time you enter validation,% w / o% is ALWAYS% w / o%.
From what I saw in the dataInicio
lifecycle, it does the first validations for later popular.
In my case, I need the first field to be filled in.
<rich:calendar
id="idDataCadastro"
locale="pt_BR"
popup="true"
value="#{dataInicio}"
datePattern="dd/MM/yyyy"
showInput="true"
label="Data de início"
showApplyButton=""
cellWidth="24px"
cellHeight="22px"
style="width:200px"
required="true" >
</rich:calendar>
<rich:calendar
id="idDataCadastro"
locale="pt,BR"
popup="true"
value="#{dataFim}"
datePattern="dd/MM/yyyy"
showInput="true"
label="Data fim"
showApplyButton=""
cellWidth="24px"
cellHeight="22px"
style="width:200px"
required="true"
validator="#{beanController.validateDataFim}" >
</rich:calendar>
public void validateDataFim(FacesContext context, UIComponent component, Object valor) throws ValidatorException {
if(valor != null){
Date dataFim= (Date) valor;
if(dataInicio != null && dataFim.before(dataInicio)){
throw new ValidatorException(new FacesMessage(
FacesMessage.SEVERITY_ERROR,
"A data fim não pode ser anterior a data inicio.",
"A data fim não pode ser anterior a data inicio."));
}
}
}