• 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

how to pre-selected s:checkboxlist

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using struts 2 checkboxlist to display the list of checkboxes... Everything works fine except I am unable to preselect the checkboxes at the time of update...
allRoles is an arraylist that contains all roles from database.
selectedRoles is also an arraylist that contains roles by each user

I want all roles with selected roles checked.

In my jsp, I wrote..

<s:checkboxlist list="allRoles" name="roles" listKey="rolesid" listValue="rolesDescription" value="selectedRoles"/>


it doesn't work.
I have search extensively on google, but no help yet.. anyone can help me please.

Thanks
 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the content of the selectedRoles ArrayList?? If I remember correctly, it should contain the keys which you want to select. So if your selectedRoles ArrayList contains some beans (objects), then you might try something like this (assuming selectedRoles contain same objects as allRoles)
 
Ankit Garg
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And welcome to javaranch aye thwe...
 
aye thwe
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello Ankit,
thank you for your reply.
yes ..selectedRoles contains objects and i change my s:checkboxlist as you told
it all works!!
really really thanks Ankit
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic