Tuesday, January 17, 2006

SimpleFormController: onSubmit() not being called

I had a SimpleFormController and a validator. According to my logs, the command object passed validation, but I was not seeing the success-view. Upon closer inspection of the errors object in my validate method, I noticed Spring was having a problem converting the String (from the form input) to the Long property of my command class.
The solution is easy -- implement initBinder() in the controller and register a PropertyEditor.

2 comments:

Anonymous said...

Hi Kenrick.
This post really got me out of a sticky situation yesterday, thanks!
Can you tell me, please, when you say "Upon closer inspection of the errors object in my validate method...", WHERE do you mean? I looked in my Validator and its Errors object, but could see no incorrect values.
To avoid similar issues in the future, I'd really like to kow where to perform my investigations.
I hope you can help.
Thanks in advance.
Frank

Ken said...

Hi Frank,
I wrote this when I was using Spring MVC 1.x. Which version of Spring MVC are you using?

If I recall correctly, I probably examined the state of the Errors object (by looking at the Tomcat console) and noticed the error.