aspose file tools*
The moose likes Struts and the fly likes how to do validation? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how to do validation?" Watch "how to do validation?" New topic
Author

how to do validation?

Liz Brown
Ranch Hand

Joined: Oct 22, 2002
Posts: 112
I have 2 fields on my jsp:
start date and end date.
I have to put some validation that the startDate user enters in always less than or equal to the end date.
(I have myAction which extends ValidatorForm. I am using validation.xml to put required field check.)
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
It sounds like you already know how to do validating for your ActionForm. What part exactly are you having problems with? Also, have you read the Struts documentation on build in validators for the ValidatorPlugin?


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
Liz Brown
Ranch Hand

Joined: Oct 22, 2002
Posts: 112
i have same problem.
I have startdate, end date.
I have validator.xml. (using validation plugin)
I have put both as required fields in this file.
but how to check if one is greater than another?
alan do
Ranch Hand

Joined: Apr 14, 2005
Posts: 354
you need to write your own custom validation. look for samples online. the most common example you'll find is the validate identical (eg. if the user entered the same password for 2 fields). base on that example, you can do your date compare validation.


-/a<br />certified slacker...yes, my last name is 'do' - <a href="http://www.luckycouple.com" target="_blank" rel="nofollow">luckycouple.com</a>
Liz Brown
Ranch Hand

Joined: Oct 22, 2002
Posts: 112
Has anybody done this before? Could you please point me to some useful information on what I am looking for.thanks.
Anything Possible
Greenhorn

Joined: May 13, 2005
Posts: 1
It looks like someone took the time to document the solution at http://www.junlu.com/msg/159728.html
alan do
Ranch Hand

Joined: Apr 14, 2005
Posts: 354
every struts developer should have a shortcut to http://struts.apache.org/userGuide/index.html

for your question, look at the validatTwoFields example in the validator docs: http://struts.apache.org/userGuide/dev_validator.html
MInu
Ranch Hand

Joined: Oct 09, 2003
Posts: 517
Write a small function for testing if the first date is greater than the second one.
then add the error to action error object.(valErrors.add("date", new ActionError("errors.date"));


God Gave Me Nothing I Wanted<br />He Gave Me Everything I Needed<br /> - Swami Vivekananda
Jason Menard
Sheriff

Joined: Nov 09, 2000
Posts: 6450
Originally posted by vinod:
Write a small function for testing if the first date is greater than the second one.
then add the error to action error object.(valErrors.add("date", new ActionError("errors.date"));


"vinod",

We don't have many rules here, but we do have a naming policy which we try to strictly enforce. Please re-read this document and edit your display name in order to comply.
MInu
Ranch Hand

Joined: Oct 09, 2003
Posts: 517
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to do validation?
 
Similar Threads
Date Validation
problem with date validation
about validation
Validation order when managed bean scope is request
OO Form Validation and Error Checking