This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes multibox and checked values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "multibox and checked values" Watch "multibox and checked values" New topic
Author

multibox and checked values

Jordan Smith
Ranch Hand

Joined: Apr 06, 2008
Posts: 89
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

Joined: Aug 29, 2008
Posts: 349
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

Joined: Nov 25, 2008
Posts: 9
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: multibox and checked values
 
Similar Threads
checkbox - initial value
checkbox iterate
form values lost in request scope
Urgent Help Required with Checkboxes!
On htm:multibox