• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

plz...help me urgent !!!!

 
Ranch Hand
Posts: 1880
Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how to validate fields using validation.xml.
can anyone explain me in detail...?
plz.. give me the sample codes...
Advance Thanx..
 
Author
Posts: 350
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you be more specific? How far did you get?
The book Professional Struts by Wrox covers it step by step. I know. I wrote that chapter.
To use the Validator Framework, follow these steps:
1.Add the Validator Plugin to the Struts configuration file.
2.Copy the validator-rules.xml and validation.xml files into WEB-INF (from the blank Struts Web application).
3.Change the ActionForm class (UserRegistrationForm.java) to the subclass ValidatorForm (org.apache.struts.validator.ValidatorForm).
4.Add a form to the form set in the validation.xml file corresponding to the attribute name of the form.
5.Add a field to the form declaration in the validation.xml file corresponding to the userName field.
6.Specify that the userName field correspond to the required, minlength, maxlength rules.
7.Add the error message for the rules to the resource bundle.
8.Specify that the username label be the first argument to the error message.
9.Configure the rules.
10. Specify that the value of the rules' minlength variable be the second argument to the error message if there is a minlength rule violation. Do the same for the maxlength variable and the maxlength rule.
11. Turn on Logging

Step 1 is to add the Validator Plugin to the Struts configuration file. The Validator Framework integrates with Struts via this Plugin, which is responsible for reading the configuration files for the Validator rules. To use the Validator Framework with Struts, you need to add this Plugin after any message resource elements in the Struts configuration file as follows:
<plug-in
className="org.apache.struts.validator.ValidatorPlugIn">
<set-property
property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
</plug-in>

Here is an example that validates a user name from a form:

The book Struts in Action also covers the Validator Framework.
 
For my next trick, I'll need the help of a tiny ad ...
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic