Feedback from "manual" validations
I have a question about input validation and user feedback. I have a Spring MVC application where i use a class (UserSubmission) for binding values on a JSP page and sending them to the controller. I use the @Valid notation in the controller to perform some validations defined by @Pattern and @Size notations on my UserSubmission class, specifically checking for required fields and verifying a correct format on the email address. This all works fine and whenever a validation rule is not fulfilled, i display an error message on the JSP page using the <form:errors> tag.
Now to my problem. There's one validation that the automatic Spring validation cannot handle. I need to call a service from the POST method in the controller to check in the database whether the chosen user id is already taken. If it is, i would like to return the user to the page with all his previously filled in fields still intact and an error message by the user name field, just like when one of the automatic validations are violated.
What is the best way to mix automatic and manual validations like this in Spring MVC?