Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts2: preselect checkbox

 
Bhaarat Sharma
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I have a checkbox in a form. There are multiple checkboxes on this form and when the form is submitted these checkboxes are validated (not using annotations).

if not all checkboxes are checked then control is coming back to the same page with an error message. But even the checked checkboxes are unchecked when control comes back to this page because of error.

according to the struts2 ui documentation the value="" attribute should be used if something needs to be preselected but its not working for me.



in my action class I have getters and setter for privacy and formcheckBox



I'd appreciate any help.

Also struts2 is automatically making hidden tags like this
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The checkbox tag will automatically take its value from the value of the property in the Action class. Just omit the value attribute entirely from the tag, and it should work fine.
 
Bhaarat Sharma
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I tried that and it is only working when my fieldValue="true" if i replace it with something else, say, fieldValud="something" it doesnt work

modified example

getters setters


are we not allowed to have anything else in fieldValue?
[ December 12, 2007: Message edited by: Anil Kumble ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic