File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Spring and the fly likes *IGNORE* SimpleFormController. Database validation in onSubmit(). Problem calling showForm() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "*IGNORE* SimpleFormController. Database validation in onSubmit(). Problem calling showForm()" Watch "*IGNORE* SimpleFormController. Database validation in onSubmit(). Problem calling showForm()" New topic
Author

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

Edward Winchester
Ranch Hand

Joined: Sep 16, 2009
Posts: 65
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!!
Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
Thanks for the update. You should also add some bold or red text in the beginning of the question.


SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: *IGNORE* SimpleFormController. Database validation in onSubmit(). Problem calling showForm()
 
Similar Threads
Neither BindingResult nor plain target object for bean name 'vids2m1' available as request attribute
New to Spring
difference between AbstractFormController & SimpleFormController
problem in form submit in spring
What is the purpose of the ContextLoaderListener