wood burning stoves 2.0*
The moose likes Struts and the fly likes Why validation at  struts ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Why validation at  struts ?" Watch "Why validation at  struts ?" New topic
Author

Why validation at struts ?

Aneesh Kumar
Greenhorn

Joined: Feb 26, 2004
Posts: 13
Why cant data validation be done at client side using javascripts ??
Itsnt it easier and faster ?
Is there any adavantage of using struts validator ??
Christopher DeBracy
Greenhorn

Joined: Feb 22, 2004
Posts: 4
The struts validator will actually generate Javascript for you, if you so choose.
Personally, I don't use Javascript validation. While the dialog box is convenient, the formatting and placement of the error messages is not to my liking. Also, if the user turns off Javascript, what happens then? I still have to validate server-side. This way they get a consistent interface from me.
However, others prefer the faster Javascript validation and the consistent display of error messages isn't that important.
Hope that helps.


SCJP 1.4<br />SCWCD<br />SCBCD
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
Actually, Struts validation supports client-side validation as well as server-side validation for simple validators. Basically, client-side validation is a nice extra but it can never completely replace server-side validation.
1) Some validations need more context than the current page and therefore client-side validation would be difficult.
2) Invalid data should never be allowed make it to the datasource and this can only be guaranteed by server-side validation. Remember, it is conceivable that the user could turn off javascript and completely bypass your client-side validation.
For the above reasons, most applications make use of a combination of both client-side and server-side validation.
Aneesh Kumar
Greenhorn

Joined: Feb 26, 2004
Posts: 13
Thanks a lot guys
These were valuble new insights .
I guess i will use both validations ..

Regards
Aneesh
anu ramk
Greenhorn

Joined: Feb 26, 2004
Posts: 3
Oh, these client-side / server-side validations drive me nuts
I am just a low level flunkey doing what the project leads and tech leads ask me to do. But I am going mad trying to figure out how to make certain fields read-only based on dynamic user choices, or how to display certain contents only in certain situations and how to scroll down pages to show certain areas without using javascript.
The business team asks for all these stuff to give a better 'user experience' and the tech leads say "Oh my god. u used javascript! No " and I feel like tearing my hair figuring these things out.
If you have any experience being in a similar situation, maybe u can help out by posting some tips on the "SetFocus on re-displayed page" thread!
I would really appreciate it.
[ February 26, 2004: Message edited by: anu ramk ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why validation at struts ?