aspose file tools*
The moose likes Struts and the fly likes Struts - Validator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts - Validator" Watch "Struts - Validator" New topic
Author

Struts - Validator

Nick Delauney
Ranch Hand

Joined: Sep 28, 2002
Posts: 43
Hello all,

I have just started using validator. For my first validation I used the "required" validation rule that comes with STRUTS validator. Required just checks to see if a field is blank and returns an error if it is.

My problem is the field will always be blank upon the initial visit to the page, so the error will always show even though the user didn't get a chance to make an error.

Does anyone know how to get around this?

Thanks,


N.D:"Anything worth having, takes time to get"
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
How are you going to the page for the first time? If it's an action, set the validate attribute of that action to "false".


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

I'd say to create an extra flag as a hidden property.
That way I think you can use requiredif to check the hidden property and only consider it required when appropriate.


A good workman is known by his tools.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts - Validator