wood burning stoves*
The moose likes Spring and the fly likes Couple of questions on how things were done prior to Spring 3 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Couple of questions on how things were done prior to Spring 3" Watch "Couple of questions on how things were done prior to Spring 3" New topic
Author

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

Ray Clark
Ranch Hand

Joined: Aug 16, 2012
Posts: 52
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

Joined: Mar 07, 2010
Posts: 1648
    
    7

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


[How To Ask Questions][Read before you PM me]
Ray Clark
Ranch Hand

Joined: Aug 16, 2012
Posts: 52
Thank you, I was able to get these to work.

As always, you've been a great help.

Ray
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1648
    
    7

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:


 
 
subject: Couple of questions on how things were done prior to Spring 3
 
Similar Threads
Testing with Spring
K&B SCJP Study Guide for Java 5 ERRATA p 419
Spring 3 @PathVariable problem with slash
Doubt in K&B SCJP 5: topic Important Facts About Strings and Memory
Spring in Action - Question