This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About checkboxList...

 
Philip Zac
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This isn't just JSP.
Are you using Struts or another framework?
 
Philip Zac
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello ben,


I am using struts and jSTL tags...

Thanks

philip
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
siddiq syed
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please can anyone send a example code for the problem above of s:checkboxlist
 
James Gadbury
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic