• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

About checkboxList...

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello ben,


I am using struts and jSTL tags...

Thanks

philip
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please can anyone send a example code for the problem above of s:checkboxlist
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic