• 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

Struts2 checkboxlist prepopulate problem

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am unable to figure out how to prepopulate a checkboxlist. The checkboxlist displays fine and works when I insert a record (i see the data in the db), but when I edit that record the checkboxlist is always blank/not populated. Using struts2/hibernate.

Student entity (many-to-many relationship with AwardCriteria)


AwardCriteria entity (many-to-many relationship with Student)


StudentAction - I get all possible criteria items and place them in awardCriteria


JSP checkboxlist - the list is set to awardCriteria (contains all possible criteria options). This allows me to save to the db fine (data in db is correct), but the checkboxlist never prepopulates when I edit a record


How can I get my checkboxlist to prepopulate? Any guidance greatly appreciated. Thanks.
 
Ranch Hand
Posts: 689
Scala Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


hi,

please change in you code at jsp for display chaeck box list.

<s:checkboxlist list="awardCriteria" label="Criteria Items" listKey="id" listValue="name" name="criteria.id" value="%{id}" />


Just change this value="%{id}"

this will solve your problem.

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic