Here are two examples:

        <logic:iterate id="product" name="products">
                <html:multibox property="productsInstalled">
                    <bean:write name="product" property="id"/>
                </html:multibox>
                <bean:write name="product" property="name"/><br>
        </logic:iterate>

This handles simple checkbox arrays.

---

However, if you want to have rows of data (more then just checkbox's), I
needed to do something like this:

    <% int i = 0; %>
    <logic:iterate id="customerContact" name="adminUpdateProfileForm"
property="customerContacts">
       <tr>
        <td class="smallFont"><input type='text' name="customerContact[<%= i
%>].contactName" value="<%=
((com.domain.app.CustomerContact)customerContact).getContactName() %>"
size=20 maxlength="<%= com.domain.app.CustomerContact.MAXLEN_CONTACTNAME
%>"></td>
        <td class="smallFont"><input type='text' name="customerContact[<%= i
%>].contactTitle" value="<%=
((com.domain.app.CustomerContact)customerContact).getContactTitle() %>"
size=30 maxlength="<%= com.domain.app.CustomerContact.MAXLEN_CONTACTTITLE
%>"></td>
        <td class="smallFont"><input type='text' name="customerContact[<%= i
%>].contactPhone" value="<%=
((com.domain.app.CustomerContact)customerContact).getContactPhone() %>"
size=20 maxlength="<%= com.domain.app.CustomerContact.MAXLEN_CONTACTPHONE
%>"></td>
        <td class="smallFont"><input type='text' name="customerContact[<%= i
%>].contactEmail" value="<%=
((com.domain.app.CustomerContact)customerContact).getContactEmail() %>"
size=20 maxlength="<%= com.domain.app.CustomerContact.MAXLEN_CONTACTEMAIL
%>"></td>
       </tr>
       <% i++; %>
    </logic:iterate>

Not the prettiest, but it works.

----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, May 30, 2001 12:39 PM
Subject: Re: Question on the ActionForm design for dynamic data?


> Hi Jeff,
>
> Does this really work for you ? It works fine for me, to put the
information to
> the screen, but the setting of the data back to the form on the return
journey,
> does not work for me. If the automatic calling of the setters supposed to
work?
>
> I have code as below ... But the call
> getRow.getElementAt(X).setCounterpartySelected(true); does not get called
!!!
> In your example, are the text values in your form REALLY being updated ?
>
> <% int i = 0; %>
> <logic:iterate name="CounterpartyFilterForm"
property="counterpartyFilterRows"
> id="row">
> <logic:equal name="row" property="counterpartySelected" value="true">
> <INPUT type="checkbox" checked name="row[<%= i
> %>].counterpartySelected">
> </logic:equal>
> <logic:equal name="row" property="counterpartySelected" value="false">
> <INPUT type="checkbox" name="row[<%= i %>].counterpartySelected">
> </logic:equal>
>
> <bean:write name="row" property="counterpartyDisplayName"/><BR>
> <% i++; %>
> </logic:iterate>
>
> Thanks in advance
> Andre Glauser.
>
> --------------------------------------------------------------------------
------
> ------------------------------------
>
>                (1) Have a Vector / Collection of contributors (ie.
> getContributors())
>                belonging to your form.  Inside that function, check to see
if
> you need
>                more rows by using code similar to the following:
>
>                    public Vector getCustomerContacts()
>

>                        CustomerContact lastCustomerContact =
>                (CustomerContact)this.customerContacts.lastElement();
>                        if (!lastCustomerContact.isEmpty())
>                // is this slot being used?
>                            this.customerContacts.addElement(new
> CustomerContact());
>                // always have one available slot at the end of the matrix
>
>                        return this.customerContacts;
>                    }
>
>                (2) Do not use the reset() method.
>
>                (3) On your JSP, use code like this:
>                    <% int i = 0; %>
>                    <logic:iterate id="customerContact"
> name="adminUpdateProfileForm"
>                property="customerContacts">
>                       <tr>
>                        <td class="smallFont"><input type='text'
>                name="customerContact[<%= i %>].contactName" value="<%=
>
> ((com.domain.project.CustomerContact)customerContact).getContactName()
>                %>"></td>
>                        <td class="smallFont"><input type='text'
>                name="customerContact[<%= i %>].contactTitle" value="<%=
>
> ((com.domain.project.CustomerContact)customerContact).getContactTitle()
>                %>"></td>
>                        <td class="smallFont"><input type='text'
>                name="customerContact[<%= i %>].contactPhone" value="<%=
>
> ((com.domain.project.CustomerContact)customerContact).getContactPhone()
>                %>"></td>
>                       </tr>
>                       <% i++; %>
>                    </logic:iterate>
>
>                (4) Have a button on the form "Add more rows" in which case
the
> form
>                posts to itself and will cause a new row to be added at the
> bottom of
>                the grid.
>
>
>                Hope this help,
>                Jeff
>
>

Reply via email to