File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

multibox and checked values

 
Jordan Smith
Ranch Hand
Posts: 89
  • 0
  • Mark post as helpful
  • send pies
  • 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?
 
Tom Rispoli
Ranch Hand
Posts: 349
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Subrata Biswas
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic