Two Laptop Bag
The moose likes Struts and the fly likes validations in struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "validations in struts" Watch "validations in struts" New topic

validations in struts

haritha hari

Joined: Nov 14, 2012
Posts: 29

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

Joined: Oct 29, 2001
Posts: 9190

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.

[How To Ask Questions On JavaRanch]
Shailesh Kumar Saxena

Joined: Dec 15, 2012
Posts: 25

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

Shailesh Saxena,
Pilibhit, U.P. INDIA
I agree. Here's the link:
subject: validations in struts
jQuery in Action, 3rd edition