How do I set the order in which validations are performed when using @Valid?

I am using the @Valid annotation to perform validations after the form is submitted. (Spring MVC 3.1 and JSR 303 implementation is Hibernate Validator)

The error messages are then displayed on the page based on these checks.

The problem is, I need to control how these messages are displayed (in other words , in what order they are displayed). I want them to appear in the same order as the fields on my page.

I know it can be done using groups, but it looks like a patch to me. Groups don't seem to be designed for this ... but maybe I'm wrong?!? Also, I don't want to define a group (new interface) for every property of my bean ... it should be easier than this ...

So my question is ... is there a way to set the order in which checks will be performed?

Thank.

+3


source to share


2 answers


There is no suitable way ... Unfortunately, the groups closest to the standard approaches. Hope this changes soon!



0


source


You can use spring tag form:errors

in jsp:



<form:errors path="varName" />
<form:input path="varName" cssClass="small" disabled="${isFormDisabled}"/>

      

0


source







All Articles