I'm using openFaces' dateChooser and I set a pattern. If I put in it a wrong value (like: 33/33/33) and try to submit the validationError is set to true because of the wrong format but I don't know how to get the specific error message or component that caused the validation error.
Here is a part of my code:
<o:dateChooser
id="DateColBtnGeneralView"
pattern="#{configurationController.defaultDateFormat}"
value="#{homeController.firstDate}">
<f:convertDateTime pattern="#{configurationController.defaultDateFormat}"/>
</o:dateChooser>
<o:commandButton
action="#{homeController.submitDates}"
onsuccess="contractClientDialogValidation(event)
value="Submit" />
function contractClientDialogValidation (event) {
if (event.validationError) {
alert("I want to show you the right error message according to the wrong value and component");
}
}
The validationError is set to true in case a required component is left empty or in case of an incorrect date format or in case an input number is too long or etc.
The validation errors are primarily related to the UpdateModelValues and InvokeApplication phases within the JSF lifecycle.
Inside your <h:form/> element you can choose to have a <h:messages id="errorMessages"/> tag.
When the ajax request/response lifecycle is complete, render the <h:messages/> tag.
See point 3 of this link