This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Other Application Frameworks and the fly likes Client side validation using Spring MVC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Client side validation using Spring MVC" Watch "Client side validation using Spring MVC" New topic
Author

Client side validation using Spring MVC

Sonny Gill
Ranch Hand

Joined: Feb 02, 2002
Posts: 1211

Hi, and welcome Rob Harrop and Jan Machacek.

There is already a topic on Spring Vs. Struts that touches on validation, but my question is a bit more specific.

What is the support for generating javascript for client side validation in Spring?

Basically, what I'd like to avoid is the code duplication for implementing the same or similar validations on the client side and then on the server side.
When using Spring MVC, Is it possible to specify validation rules in a configuration file, and have the framework generate JavaScript to enforce those, and apply those rules again before/after populating the domain object with the user supplied values?

Sonny
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
I think you can use Commons validator with Spring MVC as well. So you get client side validation there.
Sonny Gill
Ranch Hand

Joined: Feb 02, 2002
Posts: 1211

Yes, I think Matt Riable uses Commons Validator with Spring MVC for Equinox/Appfuse, I am yet to have a good look at the code though.

What I want to know is how easy it would be to set it up with Spring MVC, compared to say Struts. And whether Spring MVC has support for doing basic validation on the server using the same rules (as specified for generating client side validatino code).

Most of the people who say that they have used Spring seem to use it with another MVC framework, which makes me wonder what limitations Spring MVC has compared to the other popular products.
Matt Raible
author
Ranch Hand

Joined: Jan 11, 2001
Posts: 114
Commons Validator with Spring MVC works the same way it does with Struts - you can use it for server-side validation or server+client-side validation.


Matt<br /> <br />Author: <a href="http://springlive.com" target="_blank" rel="nofollow">Spring Live</a> and <a href="http://www.apress.com/book/bookDisplay.html?bID=256" target="_blank" rel="nofollow">Pro JSP</a><br />Weblogs: <a href="http://raibledesigns.com" target="_blank" rel="nofollow">Raible Designs</a> <a href="http://jroller.com/page/raible" target="_blank" rel="nofollow">Spring Live Blog</a>
Sonny Gill
Ranch Hand

Joined: Feb 02, 2002
Posts: 1211

Thanks Matt.

For anybody looking for information on this topic, here are a couple of helpful links -

http://jroller.com/page/raible/20040712#using_commons_validator_with_spring
https://sourceforge.net/forum/message.php?msg_id=2658797
Sonny Gill
Ranch Hand

Joined: Feb 02, 2002
Posts: 1211

This brings me to the other part of my question.
Why do most people prefer to use another MVC framework in front of Spring, what are the major drawbacks in Spring MVC at this stage?
Matt Raible
author
Ranch Hand

Joined: Jan 11, 2001
Posts: 114
My guess is folks would rather use a web framework they're familiar with - rather than learning a new one.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Client side validation using Spring MVC
 
Similar Threads
Is Spring JdbcTemplate expensive to create
Have a question about registration form
How to validate time field using validator framework of struts
what happens if i diable javascript in my browser?
requiredif Validation - Struts Client side validation