Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

validations in struts

 
haritha hari
Greenhorn
Posts: 29
Chrome Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai friends,

I am working on struts validation

validation.xml file is



And my action form is




For validating we are use validate.xml file right...?
but why we need to use validate method in action form

please tell me......

thanq in advance
 
Joe Ess
Bartender
Posts: 9312
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
haritha hari wrote: why we need to use validate method in action form


You do not. I find it useful to do simple validation with XML validation (see if a required field is filled in) and more complex validation in the Java code (make sure a field is in a set of values).
You can also create your own validators to take care of more complex cases.
 
Shailesh Kumar Saxena
Greenhorn
Posts: 25
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Haritha

As i know, we use validate.xml (or any name like validator-user.xml....) to configure the dynamic validator plugin generated validation rules.
Struts supplied validator plugin provides approx 14 validation rules. But moreover if we need our manual validation rules along with validator
plugin supplied validation rules then for this purpose we can write our own logic in action form class validate(--) method.
If you are in no need of your own manually developed validation rules, there is no need of taking the validate(--) method in your action form class.

I hope this will help you

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic