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

Validator frameork in struts

Tulip Jain
Greenhorn

Joined: Nov 08, 2011
Posts: 13
Hi all,

I have few questions regarding validator framework.

1. In struts we can do both server and client side validation so wats the diff btwn two? can i apply all validations at client side?
2. So in the client side validations, <html:javascript formName=" LoginBeanName" /> and <html:form action="LoginAction.do" onSubmit=”return validateLoginFormBean(this);”> are the only tags which i need to add in jsp page.
3. In case of server side validation, can i validate the data from Database? Can i do this? for eg if i want to check whether the user entered fake or existing bank account number?

Please reply... i am very confused ...

Thanks
Jinal Prakas Shah
Ranch Hand

Joined: Jun 20, 2012
Posts: 39
First of all both the validations are important i.e., both client and server side. If you just do client side validation then there is a high possibility that you might get data that is not validated because in client-side validation you need Javascript and if you turn it off then there will never be a validation done. So both the server and client side is important.

Yes you have to apply the 2 tags you mentioned for client-side validation

yes you can validate on the server-side with your data in database. you can return the same page if there are any validation errors by mapping it. like if there is fake account or duplicate bank account number.


Tulip Jain
Greenhorn

Joined: Nov 08, 2011
Posts: 13
Thanks a lot jinal ... it helped a lot... after your post i did some practice on validation and concept is clear now .... but i have only doubt remaining is that whatever validations we configure for client side same validations applies to server side in the configuration files. There is no way in the configuration files, where we can seperate the validations for client side and for server side....
Jinal Prakas Shah
Ranch Hand

Joined: Jun 20, 2012
Posts: 39
Tulip I am glad that I could help. There is a way to separate validations in both server-side and client-side. If you want to have extra-validations on either of the sides here's the trick. For client side you have to code specially and write in Javascript and for server-side you have code and write the flow in your action class method.

Regards
Tulip Jain
Greenhorn

Joined: Nov 08, 2011
Posts: 13
Thanks a lot Jinal .... i really appreciate your replies ....
 
 
subject: Validator frameork in struts
 
Similar Threads
purpose of javascript code in validator-rules.xml ?
Struts Validator - Client and Server side validations together
Validwhen validator client side javascript
Validwhen validator java script
struts validator. stoping on first validation error.