Integrating Hibernate Validator with Spring MVC
Remember when I wrote about Better client-side validation with Prototype back in May? Ted Bergeron responded to my post with the following comment:
Now that I am using Hibernate Annotations Validator, I stopped using commons validator. You can use the hibernate validator without using hibernate for persistence. I wrote some jsp 2.0 tag files to handle binding my form fields with spring mvc, and I use reflection to check for the validation annotations. This makes it no work to have a js calendar for all Date fields, or have class="required" added to all fields that have a @NotNull annotation. I'd be happy to send you the code for appfuse 2.0.
Ted followed up by sending me the code. I took a look at it, and reviewed a well-written PDF he'd written for his work. I told him he should publish it as an article, hooked him up with some folks at IBM developerWorks - and voila! Ted's article, titled Hibernate can meet your validation needs was published yesterday. Nice work Ted!
I'm looking forward to trying to leverage Hibernate Validation annotations for all the web frameworks in AppFuse. Should be interesting hacking into the cores of the frameworks to modify how their validation engines work.
I'll help if you decide to do it to Tapestry. (So long as it's a version I can muck around with via maven2, which is currently only 4.1 )
Posted by Jesse Kuhnert on September 13, 2006 at 07:47 PM MDT #
Then again, I'd rather see TAPESTRY-881 fixed first. ;-)
I should probably start working on Howard's code review issues pretty soon as well.
Posted by Matt Raible on September 13, 2006 at 09:28 PM MDT #
I had forgotten, but apparently there has been some work done in this area already. He says it's compatible with 4.0/4.1. Not sure if there's anything in it you can work from.
http://beanform.sourceforge.netPosted by Jesse Kuhnert on September 13, 2006 at 09:44 PM MDT #
Posted by Jesse Kuhnert on September 13, 2006 at 09:46 PM MDT #
Posted by Daniel Gredler on September 13, 2006 at 10:13 PM MDT #
Uri
Posted by Uri on September 13, 2006 at 10:58 PM MDT #
Here's to hoping the JSF and Struts 2 guys leave comments that their frameworks support Hibernate Validation annotations as well. ;-)
Posted by Matt Raible on September 14, 2006 at 12:03 AM MDT #
Posted by Jacob Hookom on September 14, 2006 at 06:49 AM MDT #
Posted by Sergey on September 14, 2006 at 07:36 AM MDT #
Regarding documentation... There will be a fairly detailed documentation as part of the springmodules documentation. We're also working on putting the springmodules samples as part of the release (currently the only way to get to them is by checking them out of cvs) where one of the samples shows a very simple example of how to use this framework along with SpringMVC. cheers,
Uri
Posted by Uri on September 14, 2006 at 09:13 PM MDT #
Posted by Sergey on September 14, 2006 at 09:40 PM MDT #
Posted by Marc on October 17, 2006 at 08:52 AM MDT #
Posted by Oliver on February 13, 2008 at 10:04 AM MST #
I asked IBM and they said they were upgrading their systems and would fix the link. That was in December.
So, I posted the article on my own site:
http://www.triview.com/articles/hibernate/validator/canmeetyourneeds.html
Everything is still pretty much current 18 months later. In my own code I re-implemented the tagfiles as subclasses of Spring's classic Taglibs to see if there was a performance difference, and bundled this code as a jar to drop into projects.
I spoke with Keith Donald at the Spring Experience about the article and trying to contribute the code. He said that he would take a look at it. However with the frosty relationship between JBoss and SpringSource, a project integrating SpringMVC and Hibernate probably wouldn't get accepted.
Posted by Ted Bergeron on February 22, 2008 at 07:07 PM MST #