JSR 303 and JVM Web Framework Support
Emmanuel Bernard recently sent an email to the JSR 303 Experts Group about the next revision of the Bean Validation JSR (303). Rather than sending the proposed changes privately, he blogged about them. I left a comment with what I'd like to see:
+1 for Client-side validation. I'd love to see an API that web frameworks can hook into to add "required" to their tags for HTML5. Or some service that can be registered so the client can make Ajax requests to an API to see if an object is valid.
Emmanuel replied that most of the necessary API already exists for this, but frameworks have been slow to adopt it.
Hi Matt,
The sad thing is that the API is present on the Bean Validation side but presentation frameworks are slow to adopt it and use it :(
RichFaces 4 now has support for it but I wished more presentation frameworks had worked on the integration. If you can convince a few people or have access to a few people, feel free to send them by me :)
The integration API is described here. Let me know if you think some parts are missing or should be improved. We should definitely do some more buzz around it.
In the interest of generating more buzz around it, I decided to do some research and see what JVM Frameworks support JSR 303. Here's what I've come up with so far (in no particular order):
- RichFaces 4 - Client Side Validation
- Tapestry's JSR 303 - Bean Validation Library
- Wicket JSR-303 Validators
- Configuring a JSR-303 Validator for use by Spring MVC
- GWT Validation
- Vaadin Bean Validation JSR 303 support
- Inline field validation in Scala/Lift using JPA and JSR 303
Struts 2 has an open issue, but doesn't seem to support JSR 303. Since I did a quick-n-dirty google search for most of these, I'm not sure if they support client-side JavaScript or HTML5's required. If you know of other JVM-based web frameworks that support JSR 303, please let me know in the comments.
While not really a JVM based web framework, Flex thanks to GraniteDS does support Bean Validation as well.
http://www.graniteds.org/confluence/display/DOC/8.+Bean+Validation+%28JSR-303%29
Posted by Emmanuel Bernard on March 08, 2011 at 07:30 PM MST #
Hi Matt,
Metawidget has JSR-303 support.
Because Metawidget wires up other frameworks, this means that Metawidget effectively adds JSR-303 support to Android, GWT, JSF (not only RichFaces), JSP, Spring MVC, Struts, Swing and SWT.
In my opinion (and I'm biased, I know) the UI frameworks should *not* be the ones directly inspecting annotations and altering their components to suit. I think that is beyond their scope. For example:
I would much rather some middleware (ie. Metawidget, OpenXava etc) takes the job of wiring UIs to domain objects, just as ORMs take the job of wiring domain objects to databases. We could think of this middleware as an Object User Interface Mapper (OIM).
Regards,
Richard.
Posted by Richard Kennard on March 10, 2011 at 02:42 AM MST #
Posted by Javier Paniza on March 10, 2011 at 08:37 AM MST #
Perhaps an honorable mentioning of the framework 'Loom' that (by reading the comments) appear to have given Bernard some 'inspiration' :-)
http://icoloma.blogspot.com/2007/12/validate-web-forms-using-jpa.html
Client side JPA validation, last release nov 2010 but does not appear to support JSR-330 yet. Have not tried the last one though.
Jens
Posted by Jens on May 09, 2011 at 05:02 PM MDT #