• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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
 
All of life is a contant education - Eleanor Roosevelt. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic