This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Couple of questions on how things were done prior to Spring 3

 
Ray Clark
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm somewhat familiar with Spring 3 and annotations, but I'm trying to do something with Spring 2.5 and I'm not sure how things were done "back then".

1) Was there a better way to populate a bean rather than pulling the data out of the request as follows? This works but surely Spring had a cleaner way to do it prior to Spring 3.



2) How was validation done with Spring 2.5? In Spring 3 I would do it as follows, I could do it the same way if I knew how to instantiate a class that implemented BindingResult. How was validation done in Spring 2.5?



Thanks,
Ray
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to be clear with Spring 2.5 you should still be using the annotation approach. You would have to go back to Spring 2.0

Anyway you will see that BaseCommandController which the other form controllers extends has a setValidator. If you set your validator on the controller then it will be used to validate the form post. If a validation failure occurs the form view is returned so the user can correct the errors otherwise the onSubmit() will be called. Take a looks at DataBinder and its implementations for getting a handle to the BindingResult.

Good Luck
 
Ray Clark
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, I was able to get these to work.

As always, you've been a great help.

Ray
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your welcome Ray. I missed the other part of your question but assuming the request is coming in as part of a form submit and you are using SimpleFormController then the onSumbit has an Object command parameter. This can be cast to whatever your command object is. So say your command object is called DvdDetails. Then you could do something like this:


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic