Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Types of validations in struts

 
Arjun Reddy
Ranch Hand
Posts: 629
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 629
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 629
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 629
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic