This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes validation_rules.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "validation_rules.xml" Watch "validation_rules.xml" New topic
Author

validation_rules.xml

manasa teja
Ranch Hand

Joined: May 27, 2002
Posts: 325
I observed there is some difference between the validation_ruls.xml described in text books/URLs and the one , i just downloaded from commons URL..
For example, in the latest validation-rules.xml, it is mentioned like this


and in the textbooks and other URLs, it is mentioned like this


Here, I am confused about teh "classname" parameter ...
Please help in understanindg this.. Is this version problem or something else...
I am totally confused abt this


MT
Eric Sexton
Ranch Hand

Joined: Sep 12, 2003
Posts: 133
The validator-rules.xml specifies which class and the methods within that class will be called for a particular rule. These methods contain the logic to perform the validation. The validator ships with the classname being: classname="org.apache.struts.validator.FieldChecks".
You can write your own validator though. The org.apache.struts.util.StrutsValidator class contains the methods for the validators that are included in the distribution. You should use these methods as your building blocks when writing your own method. I looks as if the second example you posted, a person wrote their own class called StrutsValidator and they wrote a method called validateRequired. This will get called for fields that are marked with "required".
So to make a long story short... the first one is standard and the second is one that somebody wrote for custom reasons.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: validation_rules.xml
 
Similar Threads
validation Exception !!!!!
Struts validation issue: Cannot load a validator resource
validator framework
struts validation output problem
Struts 1.2.7 Validation blues