Couple of questions on how things were done prior to Spring 3
Joined: Aug 16, 2012
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?
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.
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: