This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Struts and the fly likes Usage of html:checkbox for Multiple Entities Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Usage of html:checkbox for Multiple Entities" Watch "Usage of html:checkbox for Multiple Entities" New topic
Author

Usage of html:checkbox for Multiple Entities

sreenath reddy
Ranch Hand

Joined: Sep 21, 2003
Posts: 415
Hi

I have a scenario in which there are multiple checkboxes in the same page belonging to one logical entity(Say Hobbies with multiple options given to choose in the form of Checkbox Group).

Now in my ActionForm(Bean)i am using one get and set method with String[] as dataType.

So when the user selects multiple hobbies and clicks Submit, values gets filled properly . But during the modification scenario (like i set the hobbies to the form bean), the appropriate hobbies are not getting selected automatically though i used html:checkbox tag.

Is it that checkbox tag is not handling for Array of Values ??
Travis Hein
Ranch Hand

Joined: Jun 06, 2006
Posts: 161
the default html:checkbox struts tag likes to work with a single string property.
for many checkboxes, such as dynamic list of things, use html:multibox

here is a handy example i had,
my jsp:




then the form:



[ July 03, 2006: Message edited by: Travis Hein ]

Error: Keyboard not attached. Press F1 to continue.
sreenath reddy
Ranch Hand

Joined: Sep 21, 2003
Posts: 415
Thanks Travis .. Is there anything like this for Textbox as well ??
 
Consider Paul's rocket mass heater.
 
subject: Usage of html:checkbox for Multiple Entities