• 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

Date Validation

 
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to validate date, I have the following in validator-rules.xml,
but date validation does not work, although I have struts.jar in classPath and it has FieldChecks.class in it.
Thank you
Garandi

[ March 22, 2005: Message edited by: Garandi Garandi ]
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You haven't shown us the entry in your validation.xml. It should look something like this:

 
Garandi Garandi
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your reply, what is "<var-name>datePatternStrict</var-name>",and how am I going to use it.
Thank you in advance
Garandi
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In order for the validation framework to validate your date, it must know what format you expect the date to be in. Internally, it uses java.text.SimpleDateFormat to do this. If you look up this class in the Java API, you will find that one of it's constructors requires a format string such as the one given in the <var-value>tag of the example I gave you. The API docs will also show you the list of valid characters in this string. The <var-name> and <var-value> in the validation.xml example simply pass a parameter into the validator.

One other thing: make sure that your struts-config.xml has the following entry:



Otherwise, the validator isn't even turned on.

I'd advise you to open up the struts-examples.war that came with the download and study the example of validation that is there. One example includes a data validation. That should help you to understand how all the pieces fit together.
 
Garandi Garandi
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much.
Garandi
 
reply
    Bookmark Topic Watch Topic
  • New Topic