This week's book giveaway is in the Design and Architecture forum.
We're giving away four copies of Communication Patterns: A Guide for Developers and Architects and have Jacqui Read on-line!
See this thread for details.
  • 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

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.
 
When it is used for evil, then watch out! When it is used for good, then things are much nicer. Like this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic