Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multibox using bean

 
Rocko Smith
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic