• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

MVC 2.5 - Is it possible to get a 'summary' of binding errors?

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I wonder if anyone can help. With MVC 2.5 I am using some basic validation for my form fields. Each field in the BindingResult may or may not have validation error(s); and these are being displayed properly in my view (jsp) because they are exposed in the errors object when I use spring:bind. IE. I am successfully doing:


No problem. But what I'd now like to do (in addition to the above) is to have a summary of errors (of all fields) at the top of the page. Something like "You have 5 errors, please correct them before proceeding"
Does anyknow know if there is a 'page' level binding that exposes an errors object for all fields on the page? Or something similar?
Or will I have to maintain a counter in my validation code and add that to the model?

Cheers

Nathan
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you have multiple forms / form backing objects or only one on the page?

You should be able to get the total error count of a single bind / form using status.errorCount

You could also use the hasBindErrors tag - this is for a single form backing object at a time.

If you have multiple form backing objects then you're going to have to keep track of it yourself in the page.

If the question has more to do with placing the text at the top of the page before the form - you'll have to compute it after the form anyway, but you can just use CSS to layout your page and place that section at the top before the form.
 
Whatever you say buddy! And I believe this tiny ad too:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic