Adding a multibox to nested logic\:iterate block

This is regarding a code block that I asked about in an ealier posting titled "muliple level nested logic:iterate in struts".  I have multiple levels of logic:iterate blocks and now I need to add a checkbox that will contain a value that can be saved to a list when the form is posted.

actonwang had the answer before.  Hopefully he or someone will be able to figure this out.

Here is what I have:

<logic:iterate property="subGroupList" name="GroupPurchaseForm" id="SubGroupItem" indexId="index1">

<logic:iterate name="SubGroupItem" property="travelerList" id="traveler" indexId="index2">
     <tr>
     <td style="border:0;">
          <input type="text" name='<%="SubGroupItem["+index1+"].traveler["+index2+"].tfirstname"%>' size="25" value='<bean:write name="traveler" property="tfirstname"/>' />

     </td>
       ....

I need to add a checkbox.  I tried this:

<logic:iterate property="subGroupList" name="GroupPurchaseForm" id="SubGroupItem" indexId="index1">

<logic:iterate name="SubGroupItem" property="travelerList" id="traveler" indexId="index2">
     <tr>
     <td>
          <html:multibox property="selectedtravs">
              <bean:write name='<%="SubGroupItem["+ ctr +"].traveler["+ j +"].egrseqno"%>' />
          </html:multibox>
      </td>
     <td style="border:0;">
          <input type="text" name='<%="SubGroupItem["+index1+"].traveler["+index2+"].tfirstname"%>' size="25" value='<bean:write name="traveler" property="tfirstname"/>' />
     </td>
        ....

I also tried:

<logic:iterate name="SubGroupItem" property="travelerList" id="traveler" indexId="index2">
     <tr>
     <td>
          <html:multibox property="selectedtravs">
              <bean:write name='traveler' />
          </html:multibox>
      </td>
     <td style="border:0;">
          <input type="text" name='<%="SubGroupItem["+index1+"].traveler["+index2+"].tfirstname"%>' size="25" value='<bean:write name="traveler" property="tfirstname"/>' />
     </td>
      ....

but travelerList is a list of objects so the object is copied to the value of the box.  I think it needs to be a list of values but if I change it it breaks my other code.

Do I need to use something besides a multibox for this?  If I use a regular checkbox, how are the mulitple values posted to my form?

csait2Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

fargoCommented:
Hi,

Here is the link which clearly explains the use of multibox
http://www.johntopley.com/kb/java/0027.html

You can also refer here, this also encourages to use LabelValueBean
http://husted.com/struts/tips/007.html

what is the type for selectedtravs? Is it String[] or a list of beans?

fargo
csait2Author Commented:
Anyone else have an answer?  I have successfully used the multibox in the first level of iteration which is based on the example you gave links to, but this solution does not work in the second level of  iteration which is what I am dealing with here.  

Here is the link to the entire code:

http://www.experts-exchange.com/Web/Web_Languages/JSP/Q_21584917.html?query=nested+logic%5C%3Aitereate+struts&clearTAFilter=true

In the code sample I gave above, selectedtravs is an ArrayList.

Thanks!
csait2Author Commented:
Nevermind.  I figured it out myself this time!  Here is the solution in case anyone needs to know:

<logic:iterate name="GroupPurchaseForm" property="subGroupList" id="SubGroupItem" indexId="ctr">
     ....

<logic:iterate name="SubGroupItem" property="travelerList" id="traveler" indexId="j" >
     <tr>
     <td>
          <input type="checkbox" name="selectedtravs" value='<bean:write name="traveler" property="egrseqno"/>' />
      </td>
     <td style="border:0;">
          <input type="text" name='<%="SubGroupItem["+ctr+"].traveler["+j+"].tfirstname"%>' size="25" value='<bean:write name="traveler" property="tfirstname"/>' />
     </td>

The selected values from the checkbox are loaded into String[] selectedtravs when the page is posted.   The values for the checkboxes come from the egrseqno member of the Traveler Object.  TravelerList is a list of Traveler Objects within the SubGroupItem and SubGroupList is a list of SubgroupItems.

GranModCommented:
PAQed with points refunded (500)

GranMod
Community Support Moderator

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.