File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Validator Problem? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Validator Problem?" Watch "Validator Problem?" New topic

Validator Problem?

John Rainey

Joined: Dec 05, 2002
Posts: 17
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??
Matthew Marquand
Ranch Hand

Joined: Dec 19, 2002
Posts: 32
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.
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
That is only true for the JavaScript validation. Server side validation will report both errors.

Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
I agree. Here's the link:
subject: Validator Problem?
jQuery in Action, 3rd edition