Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 1.2 - Client and Server-side validations

 
Jim Patrick
Ranch Hand
Posts: 42
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Using the Validator framework in Struts, can we do client-side javascript validation(before submitting the form) and server-side validation(after submitting the form) to validate the fields in a form(eg: jsp)? If yes, then how? also please suggest an article/tutorial if possible.


Thanks.

 
Jim Patrick
Ranch Hand
Posts: 42
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any suggestions??
 
Bharat Chowdary
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jim Patrick wrote:Hi,

Using the Validator framework in Struts, can we do client-side javascript validation(before submitting the form) and server-side validation(after submitting the form) to validate the fields in a form(eg: jsp)? If yes, then how? also please suggest an article/tutorial if possible.


Thanks.



Check this link: Rose India _ Struts Validator framework.

Hope this helps!!
 
Jim Patrick
Ranch Hand
Posts: 42
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bharat..checked the link, but it only shows how to do the client side validation..my question was, how we can perform client-side as well as server-side validation at the same time using validator framework in struts.

 
Shankar Tanikella
Ranch Hand
Posts: 329
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jim, I have not done this but let me tell you whatever i remember from some article few years ago. Unfortunately, i donot have the article or the link

From Struts 1.1 (i suppose), there is something called DynaValidatorForm is used for server side form validation. There should be a method in this API named validate with action mapping as a parameter.

in Struts1.2 also this is available, it sits below ActionForm in hierarchy and we got to extend this one instead of ActionForm and implement validate method in form and also set the "validate" attribute in action mapping to true and should work as intended.

Moreover, the validations mentioned in validation xml actually generates a javascript method in that particular JSP where the form is used. you can view such automatic js code by view source

May be if you google for dynaValidatorForm you might get more information.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic