This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes DWR vs Spring MVC Validator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "DWR vs Spring MVC Validator" Watch "DWR vs Spring MVC Validator" New topic
Author

DWR vs Spring MVC Validator

Brian E Smith
Greenhorn

Joined: Mar 29, 2002
Posts: 11
Hi Frank,

I'm new to DWR, having used it for the first time just last week. I'm curious about what effect using DWR to validate a field on a form would have for a controller validator (Spring MVC). If I know that DWR has validated a field's value before being submitted, do you think there is still a need to use a validator class? I'm thinking if a form's values are validated by DWR before a form is submitted, there's no need for the validator.

Regards,
Brian Smith
Frank Zammetti
Ranch Hand

Joined: Dec 16, 2004
Posts: 136
Well, DWR in and of itself can't validate anything, so I'd say the implications of Spring make that assumption is, well, pretty bad for security! LOL

I have to admit up-front that I'm really not familiar with the validation features Spring offers. But, DWR allows you to call server-side code, so my *assumption* is that you could call on Spring from your Javascript code to do validations, which would in some ways make doing it again on form submission in Spring redundant. Then again, double-validation of user input is *never* redundant, so take that statement with a grain of salt

Also, since DWR makes calls through it's own servlet, I don't even think they would coexist in the sense that you couldn't use DWR to call through to Spring MVC because, as I recall, Spring MVC has it's own servlet, so it'd be like two competing controllers, which usually doesn't work.


-- <br />Frank W. Zammetti<br />Founder and Chief Software Architect<br />Omnytex Technologies<br /><a href="http://www.omnytex.com" target="_blank" rel="nofollow">http://www.omnytex.com</a><br />AIM/Yahoo: fzammetti<br />MSN: fzammetti@hotmail.com<br />Author of "Practical Ajax Projects With Java Technology"<br /> (2006, Apress, ISBN 1-59059-695-1)<br />and "JavaScript, DOM Scripting and Ajax Projects"<br /> (2007, Apress, ISBN 1-59059-816-4)<br />Java Web Parts - <a href="http://javawebparts.sourceforge.net" target="_blank" rel="nofollow">http://javawebparts.sourceforge.net</a><br /> Supplying the wheel, so you don't have to reinvent it!
Brian E Smith
Greenhorn

Joined: Mar 29, 2002
Posts: 11
I added the DWR entries to my web.xml, in addition to the entries for my DispatcherServlet. In dwr.xml, I described the object (which I named DWRLogonValidator) that I wanted my JSP to use to validate the individual fields on the form. In the JSP, I added the .js includes that DWR generates. It "works" as I think it should, and this mean that the data has to pass my DWR validator before I actually submit the form to the controller. So I guess my DWR validator doesn't necessarily have to supercede or make obsolete my Spring validator; I suppose they could complement each other.

Regards,
Brian
 
Don't get me started about those stupid light bulbs.
 
subject: DWR vs Spring MVC Validator