java


Spring MVC How to sort BindingResult form with hibernate validator errors


I have a huge problem with BindingResult errors order. let's say we have:
public class MyForm {
#NotEmpty(message = "Not empty")
private String name;
#Email(message = "Not valid email")
private String email;
}
And my controller:
#RequestMapping(value = "/my-url", method = RequestMethod.POST)
public String execute(#Valid #ModelAttribute("form") MyForm form, BindingResult result, Model model) {
if(result.hasErrors()) {
//I need to sort the list here
return "/my-url";
}
//rest of the code
}
BindingResult extends AbstractBindingResult,and you can get errors list, but it's implementation looks like this (AbstractBindingResult.class):
private final List<ObjectError> errors = new LinkedList<ObjectError>();
#Override
public List<ObjectError> getAllErrors() {
return Collections.unmodifiableList(this.errors);
}
Finally I'm unable to sort this list, change it or do anything else. I tried reflection, but it's not a good solution. Is there any other way to keep errors in same order as fields in MyForm ?

Related Links

Type mismatch: cannot convert from void to int
cvc-complex-type.2.4.a:Invalid content was found starting with element 'bean'
Removing a JPanel from a JFrame from a different class(and adding a new one)
Why does not Iterator have add method whereas List Iterator has one in Java?
How to transfer files using netty?
Java/Swing app Freezes randomly
add or delete library in project in eclipse plugin development
How to “link” distributed Akka actor systems?
error shown in jsp form when using errors tag
Issue retrieving longitude/latitude using Google Static Maps
Please explain Java ^ operator with examples
Android eclipse project recovery from zip file
In java, how to call the values from input class?
Is this the right definition of 'private' access modifier in java?
JavaFX/ScalaFX, WPF like Scene creation
jasper reports alternative to poi jar

Categories

HOME
ibm-bluemix
client
deployment
pypi
openmp
netsuite
proxy
server
deezer
pycharm
sd-card
gis
rsync
infragistics
graphql
sqlite3
jxls
binary-tree
webpack-2
yum
enterprise-library-5
bs4
webrequest
applepay
google-translate
midi
offline
google-cloud-spanner
orchardcms
decimal
samoa
firefox-webextensions
lucene.net
introduction
jtextfield
tokenize
wkwebview
kvc
numerical-methods
fish
facet
tooltipster
neo4j-spatial
vision
lightswitch-2013
google-rich-snippets
frame
catel
accelerate-framework
y86
wpf-controls
libraries
occlusion
ssjs
webdriver-manager
angularjs-factory
email-templates
android-tabhost
node-gyp
eclipse-gef
sas-jmp
osx-mavericks
youcompleteme
termination
apache-fop
datastax-startup
typescript1.8
dropbox-php
veracode
fancybox-2
knockout-components
feeds
sybase-asa
windows-mobile-6.5
mcafee
color-profile
crosswalk-runtime
google-cdn
hover-over
dataview
hsv
iad
cartesian-product
collapse
rgeo
embedded-code
deis
responsive-images
operation
key-management
fscommand
website-monitoring
fpml
java-metro-framework
preferences
heisenbug
picturefill
ember-charts
message-driven-bean
stxxl
oam
gridfs
web2py-modules
tws
cos
shellexecute
xamlparseexception
sabredav
e4x
dmoz
errai
netdna-api
adk
whoosh
boost-filesystem
vdsp
self-extracting
file-comparison
calling-convention
krl
winbugs14
jmock
zend-translate
gallio
dentrix
icanhaz.js
nintendo-ds
kdbg
mtj
zune

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App