difference between and validate() and validation.xml
Rajendra Prakash
Ranch Hand
Joined: Sep 10, 2009
Posts: 293
posted
0
I want difference between and validate() and validation.xml and validator-rules.xml
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35258
7
posted
0
The Servlet API does not use files called validation.xml and validator-rules.xml; are you referring to some 3rd party library? And which class is supposed to have a "validate()" method?
The validate () method doesnt exist in servlet API rather these methods are from 3rd party like in struts where we can use the validate framaework and can the files which you have mentioned .
In validator-rules .xml we define the validation condition of the fields of our form and call then call
validate method to validate form in struts validator_rules.xml in our action class. We need to give path of all these configuration files in our web.xml file.
See some example of struts validator and runt that example and you will be able to understand well.
(Slight expansion: validate() can be used to implement business-oriented logic that can't easily be put into XML configuration. The two XML files differ in that one generally contains the validators themselves, while the other contains the validations. That's an arbitrary distinction, since both files are listed in the Struts configuration.)
What else do you want to know that wasn't provided here or in the Struts 1 documentation?
Alpesh Padra
Ranch Hand
Joined: Jan 10, 2010
Posts: 41
posted
0
Validate() method is responsible for server side validation. Like validate user name / password with permission.
It's part of struts framework.
validation.xml & validation-rules.xml is responsible for client side validation like java script validation.
It's part of validation framework.
Validation framework is plugin for struts framework.
I mean validate() method in ActionForm . what situations validation.xml used and what situation validate()
method in ActionForm used
M Turner
Greenhorn
Joined: Dec 16, 2009
Posts: 25
posted
0
Whether you put a given validation in an xml file or into the Java action depends on how complex the validation is. If you have validations that fit with in standard parameters that can be checked using the "bundled" validation types like "required,email,stringlength" then put those in your validation.xml file. If your validations are more complex then you can action's use the validation() method. In fact, you can use both together.
Rajni Patel
Ranch Hand
Joined: Sep 03, 2009
Posts: 84
posted
0
I try to use validate() method and validation.xml both with the same action form with different field, but only validate() method populate but validation.xml rule is not populate. Please anybody could guide me?