Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6130335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:50:47+00:00 2026-05-23T16:50:47+00:00

I am using the hibernate implementation of jsr303 for server side validation. When Set<ConstraintViolation<?>>

  • 0

I am using the hibernate implementation of jsr303 for server side validation. When Set<ConstraintViolation<?>> is returned I immediately add the errors to a BindingResult for display on the page. I display the errors with a form:errors tag all in one location. The errors display on the page in any random order. Is there any way to coax Spring into displaying the errors according to the order of the fields on the page?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:50:47+00:00Added an answer on May 23, 2026 at 4:50 pm

    You can sort the field errors using a custom Comparator:

    private static final Comparator<FieldError> FIELD_ORDER_COMPARATOR = new Comparator<FieldError>() {
    
        // Your fields, ordered in the way they appear in the form
        private static final List<String> FIELDS_WITH_ORDER = ImmutableList.of("field1", "field2");
    
        @Override
        public int compare(FieldError fe1, FieldError fe2) {
    
            String field1 = fe1.getField();
            String field2 = fe2.getField();
    
            int field1Index = FIELDS_WITH_ORDER.indexOf(field1);
            int field2Index = FIELDS_WITH_ORDER.indexOf(field2);
    
            return NumberUtils.compare(field1Index, field2Index);
        }
    });
    
    ...
    
    List<FieldError> fieldErrors = bindingResult.getFieldErrors();
    Collections.sort(fieldErrors, FIELD_ORDER_COMPARATOR);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Hibernate's implementation of JPA and am seeing poor performance as multiple SQL
I'm using JPA (Hibernate's implementation) to annotate entity classes to persist to a relational
I have been using Hibernate ORM, which is an implementation of the JPA specification
I'm using JPA 2 with Hibernate 3.6.8 as the implementation. Let's say we have
I'm using JPA (Hibernate implementation) to save objects to the database. Selecting works fine,
I'm using Hibernate's EntityManager as a JPA implementation. What I want is logging of
My web application is using Java, Hibernate's JPA implementation (EntityManager) and Spring. What are
Hi I am using JPA2 with Hibernate implementation and I got a simple mapping
When using Hibernate and Ehcache as a second-level cache (2LC) implementation, is (or can)
I'm using JPA2 and Hibernate implementation. I'm trying to persist a User object, which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.