How can I validate that start date occors on or before end date?
I am using jDev 11.1.1.6.0
I have a effectiveStartDate and and an effectiveEndDate and I want to validate that if both dates are specified, that the effectiveEndDate occurs on or after the effectiveStartDate.
I have added validators in my backing bean as shown below, but there is still a problem
Consider the following scenario:
1) set effectiveStartDate to 1/1/2011
2) set effectiveEndDate to 1/1/2010
I get the validation, as expected. Now
3) I change effectiveStartDate to 1/1/2010, but the validation message remains on effectiveEndDate because I did not update the effectiveEndDate.
Can I remove the faces message somehow?
Can I re-trigger the validation?
My .jsff page contains
<af:inputDate label="#{ZspBusinessRulesAttrBundle['ColAttr.StartDate.RuleFolderEffectiveStartDate.RuleFolderEO.EffectiveStartDate']}"
id="id1"
value="#{pageFlowScope.manageRuleFolder.effectiveStartDate}"
autoSubmit="true" required="false"
validator="#{pageFlowScope.manageRuleFolder.startDateValidator}"
partialTriggers="id2">
<af:convertDateTime pattern="#{applCorePrefs.dateFormatPattern}"/>
</af:inputDate>
<af:spacer width="10" height="10" id="s4"/>
<af:inputDate label="#{ZspBusinessRulesAttrBundle['ColAttr.EndDate.RuleFolderEffectiveEndDate.RuleFolderEO.EffectiveEndDate']}"
id="id2"
value="#{pageFlowScope.manageRuleFolder.effectiveEndDate}"
autoSubmit="true" required="false"
validator="#{pageFlowScope.manageRuleFolder.endDateValidator}"
partialTriggers="id1">
<af:convertDateTime pattern="#{applCorePrefs.dateFormatPattern}"/>
</af:inputDate>
My backing bean contains
public void startDateValidator(FacesContext facesContext,
UIComponent uIComponent, Object object) {
Date startDate = (Date)object;
if (!Utility.validateStartDateAndEndDate(startDate,
effectiveEndDate)) {
throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR,
Resource.getValidationEndDate(),
null));
}
}
public void endDateValidator(FacesContext facesContext,
UIComponent uIComponent, Object object) {
Date endDate = (Date)object;
if (!Utility.validateStartDateAndEndDate(effectiveStartDate,
endDate)) {
throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR,
Resource.getValidationEndDate(),
null));
}
}