I think I am doing the same thing that you want to do using the
html:multibox. When the form is submitted you get an array of the ids that
are checked and then you can go delete them.

in the jsp form (where restaurant id is a key for the item being deleted):
<logic:iterate id="restaurant" name="favoriterestaurants">
...
        <html:multibox property="favoriteRestaurantRemoveList">
                <bean:write property="restaurantId" name="restaurant"/>
        </html:multibox>
...
</logic:iterate>


in the form class:
    private Long favoriteRestaurantRemoveList[] = new Long[0];

    public Long[] getFavoriteRestaurantRemoveList() {
        return (this.favoriteRestaurantRemoveList);
    }

    public void setFavoriteRestaurantRemoveList(Long
favoriteRestaurantRemoveList[]) {
        this.favoriteRestaurantRemoveList = favoriteRestaurantRemoveList;
    }

I am not sure if initializing the array to new Long[0] is necessary,
probably not.

> -----Original Message-----
> From: Tony Karas [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, May 09, 2001 12:50 PM
> To: [EMAIL PROTECTED]
> Subject: Posting Collections
>
>
> Briefly, this is what I am trying to achieve:
>
> - Retrieve a list of items from a database
> - Display each item with a corresponding checkbox
> - Display a "Delete" button - which when pressed deletes all
> checked items.
>
> Unfortunately, although I have managed to display the items
> correctly and
> set the checkbox value using boolean values, when I do the
> form submit - my
> ActionForm properties do not get filled in.
>
> This is the code I have:
>
> My ActionForm looks like this:
>
> public class RetailerForm extends ActionForm
> {
>     protected Vector retailer;
>
>     /*
>      * On construction, fill the form with all the retailers
>      */
>     public RetailerForm() throws SQLException
>     {
>          //here i have some code to generate my vector
>          //which is comprised of "Retailer" beans.
>     }
>
>     public Retailer getRetailer( int index )
>     {
>         return (Retailer)retailer.elementAt( index );
>     }
>
>     public Vector getRetailer()
>     {
>         return retailer;
>     }
>
>     public void setRetailer( Vector value )
>     {
>         retailer = value;
>     }
> }
>
> My "Retailer" bean has get and set elements for properties
> called "delete"
> and "name".
>
> My struts code looks like this (obviously within <html:form> tags):
>
> <logic:iterate id="retailer" name="retailerForm" property="retailer">
>       <tr>
>       <td><html:checkbox name="retailer" property="delete"/></td>
>       <td><bean:write name="retailer" property="name"/></td>
>       </tr>
> </logic:iterate>
>
> And this all works ok for displaying the data.  However, when
> I do the
> submit my "delete" property for each bean is not set and I have added
> debugging code to the "set" method and this is not called by
> struts.  I
> don't get error messages - it just doesn't happen.
>
> I know other people have had this problem, but I am
> struggling to find a
> solution.
>
> Can anyone help me?  Is there a better way of achieving what
> I am trying to
> achieve?  If I am doing the correct thing, what's the reason it's not
> working.
>
> All help appreciated.
>
> Cheers
> Tony
> ______________________________________________________________
> ___________
> Get Your Private, Free E-mail from MSN Hotmail at
http://www.hotmail.com.

Reply via email to