• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Client side validation using Spring MVC

 
Ranch Hand
Posts: 1211
Mac IntelliJ IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you can use Commons validator with Spring MVC as well. So you get client side validation there.
 
Sonny Gill
Ranch Hand
Posts: 1211
Mac IntelliJ IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sonny Gill
Ranch Hand
Posts: 1211
Mac IntelliJ IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1211
Mac IntelliJ IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My guess is folks would rather use a web framework they're familiar with - rather than learning a new one.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic