Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts - Validator

 
Nick Delauney
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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".
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic