• 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

multibox and checked values

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I am using the following code to generate a mulibox values:

interestsForm looks like that:


I need to display some of the values as checked.
I will depent it on the data base that I will return in String all the interests that the user alreay has.
I thought to create another variable:
private String[] checkedItems = ... // i will get it from DB;
and if the itme is in the checkedItems - it will display checked next to it.

What is the way to do it?
 
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I'm understanding your problem correctly I think all you need to do is store your DB values in your selectedItems property before the JSP is run.
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try below code -
<logic:iterate id="item" property="items">
<html:multibox property="selectedItems">
<bean:write name="item" />
</html:multibox>
<beam:write name="item" />
</logic:iterate>

As per above code - you should have two properties in your form/bean. One is items and second one is selectedItems.
if any Item from selectedItems is present inside items that check box will apear as checked else not.

Hope it will solve your issue.
 
No prison can hold Chairface Chippendale. And on a totally different topic ... my stuff:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic