Validating a table's contents with a JSF validator

Hi all

I have a screen that needs some regular validation of fields (e.g. required input, etc), but also some more advanced validation, where the contents of a table needs to meet certain requirements. I currently use the built-in JSF-based validation to validate the individual fields, and then call a web service in an action to validate the table.

This works, but as I’m sure you can imagine it unfortunately results in a “two step” validation error, where the JSF errors appear first, and once the user has fixed those and hit Complete the custom errors appear. Pretty terrible UX.

Is there any way to attach a custom validator to the table, and have it call backend validation with that table’s contents? Then I’d get all the error messages at once, which would be much better.

Or another solution?



Have you tried overriding the afterProcessValidations() method of your page bean? Putting additional custom validation logic there should participate in the ‘validation’ phase.

For example:

protected void afterProcessValidations() {
    //TODO: add custom validation logic here
    //delegate the the rest to the original method