File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Multibox using bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Multibox using bean" Watch "Multibox using bean" New topic
Author

Multibox using bean

Rocko Smith
Greenhorn

Joined: Jul 12, 2005
Posts: 10
I have a bean efine that contains an arraylist. Each object in arraylist contains an accountId, which is displayed and exemptStatus, which represents the check in the checkbox. Could someone show me how I can get the check to show-up in the checkbox using multibox and an arraylist?


<bean efine id="exemptBtnData" name="erateExemptStatusForm" property="btnListToDisplay" type="java.util.ArrayList"/>


<logic:iterate id="exemptBtns" name="exemptBtnData" type="com.sbc.ctf.model.ExemptStatusList" >
<bean:write name="exemptBtns" property="accountId"/>
<html:multibox name="erateExemptStatusForm" property="selectedBtns">
<bean:write name="exemptBtns" property="exemptStatus"/> </html:multibox>
</logic:iterate>
Rocko Smith
Greenhorn

Joined: Jul 12, 2005
Posts: 10
I know the above description might be confusing. Let me rephrase my question;

I have a bean defined as an arraylist. I want to know if I can use an arraylist with the multibox or does it need to be a string array?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
While you can use an Arraylist to create the checkboxes using <html:multibox>, it's important that the "property" you specify be a String array. In your example, selectedBtns must be a String array.

For what you want to do, I'd suggest using <html:checkbox> instead of <html:multibox>. Use an indexed property to identify the checkbox.

This link tells you how to use indexed properties. Note that while using indexed properties, you must either put the ActionForm in session scope, or use a Lazy Initialization technique with the ActionForm bean.
[ May 30, 2006: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Multibox using bean