This week's book giveaway is in the Java in General forum.
We're giving away four copies of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 and have ishori Sharan & Adam L Davis on-line!
See this thread for details.
Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Validator Problem?

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using struts 1.1b3 release. When I am doing validation, I set up 2 fields in my validation.xml file. I have both fields as required. Field 1 has to also validate a minlength and Field 2 has to validate against a range. The following will illustrate the issue I'm having.
Situation #1
Field 1: (leave blank)
Field 2: (leave blank)
Error Messages:
Field 1 is required
Field 2 is required
Situation #2
Field 1: hello (this should fail validation)
Field 2: (leave blank)
Error Messages:
Field 2 is required
In situation #2, I would also expect an error message from Field 1 stating that it does not meet the minlength rule. Instead, it looks like the validator is making the user enter in all of the required fields before going forward with any validation.
I was wondering if anyone else had noticed this behavior??
Thanks
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm no validator guru on struts other than playing with it a bit. However, if memory serves me right, if you look at the javascript generated for the button, you'll see that it sequentially calls each generated javascript function. If the called function says it failed validation, then it stops.
Long story short. It will only emit errors for one "kind of" validation and those must be fixed before it will even attempt to validate other aspects of the properties on the page.
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is only true for the JavaScript validation. Server side validation will report both errors.
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic