Mike,

Hi.  This is a common problem, and there is quite a bit in the archive under
Grid/Matrix.

It requires that your name for the checkbox is indexed to correspond to the
underlying collection index.  Currently you have to use scriplets (examples in
archive), or use Jeff Trent's code which he posted.  You'll see from my previous
mail that I have been adding functionality to the existing struts tags to do the
same thing.

Cheers,

Dave





"Mike Thompson" <[EMAIL PROTECTED]> on 06/14/2001 03:03:00
PM

Please respond to [EMAIL PROTECTED]

To:   [EMAIL PROTECTED]
cc:    (bcc: David Hay/Lex/Lexmark)
Subject:  adding checkbox to form



I am displaying a collection of beans in a form with <logic:iterate>.  Here is
the loop
    <html:form action="updateservices.do" name="serviceForm"
               type="com.instanton.secureex.web.form.ServiceForm">
        <logic:iterate id="service" name="services">
            <TR>
                <TD align="center">
                <html:text name="service" property="name"/>
                </TD>

                <TD align="center">
                <html:checkbox name="service" property="authenticated"/>
                </TD>

                <TD align = "center">
                <html:checkbox name="service" property="encrypted"/>
                </TD>
            </TR>
        </logic:iterate>

        <TR>
            <TD></TD><TD></TD>
            <TD align="right">
                <html:submit>
                    <bean:message key="main.update"/>
                </html:submit>
            </TD>
        </TR>
    </html:form>

Note I am not using any getter setter methods from the form itself.  What I
would like to do is add a checkbox for each row for a delete and an update
button.  The update would rip through the collection and update the appropriate
rows and delete the row if the delete button was checked.  Seems pretty
standard.  I am not sure how to go about doing this.  In my action, how do I get
a hold of my original collection?  How do I get a hold of the values of the
checkboxes?  How do I use the ActionForm in this case when I am not reading data
from it?  Would I use the ActionForm to pass the checkbox and updated items to
the action class?  How are getter/setter methods handled when I have a
collection?

    --confused

Michael R. Thompson
http://www.instanton.com
512.439.3815
I am displaying a collection of beans in a form with <logic:iterate>.  Here is the loop
    <html:form action="updateservices.do" name="serviceForm"
               type="com.instanton.secureex.web.form.ServiceForm">
        <logic:iterate id="service" name="services">
            <TR>
                <TD align="center">
                <html:text name="service" property="name"/>
                </TD>
 
                <TD align="center">
                <html:checkbox name="service" property="authenticated"/>
                </TD>
 
                <TD align = "center">
                <html:checkbox name="service" property="encrypted"/>
                </TD>
            </TR>
        </logic:iterate>
 
        <TR>
            <TD></TD><TD></TD>
            <TD align="right">
                <html:submit>
                    <bean:message key="main.update"/>
                </html:submit>
            </TD>
        </TR>
    </html:form>
 
Note I am not using any getter setter methods from the form itself.  What I would like to do is add a checkbox for each row for a delete and an update button.  The update would rip through the collection and update the appropriate rows and delete the row if the delete button was checked.  Seems pretty standard.  I am not sure how to go about doing this.  In my action, how do I get a hold of my original collection?  How do I get a hold of the values of the checkboxes?  How do I use the ActionForm in this case when I am not reading data from it?  Would I use the ActionForm to pass the checkbox and updated items to the action class?  How are getter/setter methods handled when I have a collection?
 
    --confused
 
Michael R. Thompson
http://www.instanton.com
512.439.3815

Reply via email to