This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Struts and the fly likes About checkboxList... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "About checkboxList..." Watch "About checkboxList..." New topic
Author

About checkboxList...

Philip Zac
Ranch Hand

Joined: Apr 27, 2008
Posts: 66
hello all,

I need help regarding the checkboxList.

I have a class named HWB



and action class



And in JSP page




I get the correct number of checkboxes but the checkbox along with its name is "Plan{id=2, name='Continental Plan', hotel=Hotel{id=5, name='Spice Package 1'}}". How can I make this name as
"Continental Plan"rather than Plan{id=2, name='Continental Plan', hotel=Hotel{id=5, name='Spice Package 1'}}.

Thank you.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

This isn't just JSP.
Are you using Struts or another framework?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Philip Zac
Ranch Hand

Joined: Apr 27, 2008
Posts: 66
hello ben,


I am using struts and jSTL tags...

Thanks

philip
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The list and name attribute should not be the same. You need two collections: One for the possible options, and another for the options actually selected. The latter works best if it's a String array. Also, since you specified a listKey attribute, there's no need to specify a value attribute.


Merrill
Consultant, Sima Solutions
siddiq syed
Greenhorn

Joined: Aug 14, 2008
Posts: 6
Hi Philip,

I have a similar secnario where i need to get the object from the multi selection check box.

I need to retreivew those object that has been selected by user.
Can you kindly let me know how can we achieve this in struts 2 using <s:checkboxlist />

Can you please send me a sample example.

Thanks in advance.

Regards
Siddiq.
Sourav Som
Greenhorn

Joined: Nov 13, 2008
Posts: 3
Same problem I am facing for delete
On click of Delete button both records are getting deleted inspite of one selection.I have use <s:checkboxlist ..
Newbie to Struts 2.0(infact Web development itself)
Any help please..its urgent


Thanks in Advance..<br />Sourav
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Also, since you specified a listKey attribute, there's no need to specify a value attribute.

The "value" attribute defines the currently-selected values; "listKey" is the object property that will be used as the checkbox value, "listValue" will be used as the field content.

In the OP the value is almost certainly incorrect.
Sourav Som
Greenhorn

Joined: Nov 13, 2008
Posts: 3
Please can anyone send a example code for the problem above of s:checkboxlist
James Gadbury
Greenhorn

Joined: Mar 20, 2009
Posts: 24
Hi all,

Sorry to hijack the thread but it is relevant - I too am having problems pre-populating a checkboxlist.

I have a List containing an enum of a type I defined called Role. I am trying to pre-populate a checkboxlist using the following code:



getRoles returns List<Role>, and I can see the list contains two entries, for example when I inspect the object: [ROLE_PROVIDER, ROLE_ADMIN]. Unfortunately, my check boxes are not pre-populated (i.e. none of them are checked).

Thanks in advance for reading. Kind regards,

James
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: About checkboxList...
 
Similar Threads
Doubt in checkboxlist
checkboxlist- items checked
Duplication des labels checkboxlist et optgroup
checkboxlist alignment
Struts 2 checkboxlist error - list key could not be resolved