This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes Struts-Validation For Disabled Fields Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts-Validation For Disabled Fields" Watch "Struts-Validation For Disabled Fields" New topic
Author

Struts-Validation For Disabled Fields

James Gordon
Ranch Hand

Joined: Aug 09, 2002
Posts: 106
Hi,
There is something which bother me with the Struts Validator - I'm using it for client-side validation (Javascript).
It doesn't seemed to be able to cater well for fields which are disabled, by means of having the property readonly="true" - required fields.
When I check the validation scripts in validation-rules for the "required" rules, it seemed that there is a statement which would setfocus on it. To be exact, it is "focusField.focus();". I believe this statement causes some problem for disabled fields as the focus can't be set.
Any comments?

Thanks in advance.
Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 566
That all sounds logical. What's the problem?


I have seen things you people would not believe, attack ships on fire off the shoulder of Orion, c-beams sparkling in the dark near the Tennhauser Gate. All these moments will be lost in time, like tears in the rain.
James Gordon
Ranch Hand

Joined: Aug 09, 2002
Posts: 106
Hi,
Had just found out that disabled fields are not even passed during form submission. That should be the reason as to why the validator is not working well.
Perhaps I should enable it back just before the validation so that everything works fine.

Thanks.
Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 566
Whenever I use a disabled field, I put the value in a hidden field as well so that it does get submitted. A dirty hack I guess, but you get used to it
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Struts-Validation For Disabled Fields
 
Similar Threads
Design advice needed. Data validation
I want Struts validator to ignore fields not present
Group variable validation
Validating some extra fields of action form not in my jsp?
required field...but only if enabled