File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Types of validations in struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Types of validations in struts" Watch "Types of validations in struts" New topic
Author

Types of validations in struts

Arjun Reddy
Ranch Hand

Joined: Nov 10, 2007
Posts: 627
Hi All,

I have three questions.

1). What are the ways we can actually perform validation in struts? I think it's Using validation framework(validation.xml) and the other is in the validate method of the form bean. Am I correct?

2). Can we do validation as mentioned above in both struts 1.1 and struts 2.0?

3). What is Dynavalidation then?

Thanks.


Be Humble... Be Nice.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Sounds like interview questions.

Validation in S2 is different than in S1.

The docs for DynaValidatorForm (and DynaValidatorActionForm) explain what they are and how they're different.
Arjun Reddy
Ranch Hand

Joined: Nov 10, 2007
Posts: 627
Originally posted by David Newton:
Sounds like interview questions.

Validation in S2 is different than in S1.


Yeah I am preparing for an interview . Is this true guys?? That we can not use validation framework we use in struts 1.0 in struts 2.0?

Thanks.
Arjun Reddy
Ranch Hand

Joined: Nov 10, 2007
Posts: 627
I've been readin online about using validation framework in Struts 2.0 and these are the changes I basically found from what we do normally in Struts 1.1. Please correct me if I am wrong.

1). Validation.xml file should be named as yourActionClass-Validation.xml
2). Validate=true is written in Jsp form tag
3). Error messages are written in the validation.xml file too within the <message tag> instead of using an Resources file.

Thanks.
[ December 17, 2008: Message edited by: Arjun Reddy ]
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

That's one way of doing validation in S2, there are others.

The form tag's "validate" attribute is related to client-side validation.

S2 validation messages may be resources, or specified explicitly in the validation XML. You can also validate with annotations.

I'd recommend actually writing some S2 code rather than just "knowing" it by reading the documentation or asking questions--the only way to actually learn something is by doing.
Arjun Reddy
Ranch Hand

Joined: Nov 10, 2007
Posts: 627
Originally posted by David Newton:
That's one way of doing validation in S2, there are others.

The form tag's "validate" attribute is related to client-side validation.

S2 validation messages may be resources, or specified explicitly in the validation XML. You can also validate with annotations.

I'd recommend actually writing some S2 code rather than just "knowing" it by reading the documentation or asking questions--the only way to actually learn something is by doing.


Okie David. Thanks.
 
GeeCON Prague 2014
 
subject: Types of validations in struts