I have a form with a field validated using an AJAX request on blur, both form and AJAX requests go to the same page. Sometimes when I submit an invalid form with the AJAX-validated field filled as last, the form will return with no values and no errors shown (should return with last values and validation errors above).
I tracked the issue down to the form's ValidatorTracker in form re-display request being a different object than the one that I store validation errors in. I have no conclusive proof but I believe what happens is that a race condition occurs between the submit - redirect back to form logic and the AJAX field validation (the AJAX validation is fired the same instance as form submit since it's the last field of the form). The form's validation tracker is by default taken from the defaultValidationTracker property which has PersistenceConstants.FLASH (i.e. stored until next request). I think that the cause of ValidationTracker not being the same in re-display and in submit request might be the AJAX validation request (or its critical part) getting in between the two requests used for form submission and re-display, like this:
- form submit (creates a ValidationTracker and stores errors in it)
- AJAX validation request ("eats up" the ValidationTracker's lifetime of "until next request")
- form re-display request (creates a new ValidationTracker with no errors in it)