This week's book giveaway is in the Beginning Java forum.
We're giving away four copies of Learn Java with Math: Using Fun Projects and Games and have Ron Dai on-line!
See this thread for details.
Win a copy of Learn Java with Math: Using Fun Projects and Games this week in the Beginning Java forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

*IGNORE* SimpleFormController. Database validation in onSubmit(). Problem calling showForm()

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

EDIT: No longer a question I need an answer to!

I have a controller to handle a login form. It extends Spring's SimpleFormController. According to the documentation for this controller (see http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/web/servlet/mvc/SimpleFormController.html):


The submit behavior can be customized by overriding one of the onSubmit methods. Submit actions can also perform custom validation if necessary (typically database-driven checks), calling showForm in case of validation errors to show the form view again.



This is what I want to do. Please note: I have a validator linked to the form which I want to deal with "plain data" validation only. I don't want to do the database-driven validation there.

I'm now looking at the documentation for the showForm() methods (http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/web/servlet/mvc/SimpleFormController.html#showForm(javax.servlet.http.HttpServletRequest,%20javax.servlet.http.HttpServletResponse,%20org.springframework.validation.BindException)). They take an object of BindException so figure I have to create one to pass to showForm().

Looking at the documentation for BindException: (http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/validation/BindException.html) and I get informed that:


As of Spring 2.0, this is a special-purpose class. Normally, application code will work with the BindingResult interface, or with a DataBinder that in turn exposes a BindingResult via DataBinder.getBindingResult().



So, can someone please tell me what I need to do, or how I can perform my database-backed validation?

Thanks,

Ed

EDIT: the onSubmit receives the a BindException object called errors! I really apologise for the post!!
 
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the update. You should also add some bold or red text in the beginning of the question.
 
Time is the best teacher, but unfortunately, it kills all of its students - Robin Williams. tiny ad:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!