This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts-Validation For Disabled Fields

 
James Gordon
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 567
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That all sounds logical. What's the problem?
 
James Gordon
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 567
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic