aspose file tools*
The moose likes Struts and the fly likes Date Validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Date Validation" Watch "Date Validation" New topic
Author

Date Validation

Garandi Garandi
Ranch Hand

Joined: Jan 07, 2003
Posts: 192
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 ]
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
You haven't shown us the entry in your validation.xml. It should look something like this:



Merrill
Consultant, Sima Solutions
Garandi Garandi
Ranch Hand

Joined: Jan 07, 2003
Posts: 192
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

Joined: Feb 15, 2005
Posts: 4864
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

Joined: Jan 07, 2003
Posts: 192
Thank you very much.
Garandi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Date Validation