Ah sorry Hal - thanks for your perseverance - I was assuming, mistakenly,
that multibox was something else. I'll take a look at this - cheers.
Tony
>From: "Deadman, Hal" <[EMAIL PROTECTED]>
>Reply-To: [EMAIL PROTECTED]
>To: [EMAIL PROTECTED]
>Subject: RE: Checkbox Arrays
>Date: Thu, 10 May 2001 12:20:58 -0400
>
>I posted this same response to your Posting Collections question yesterday.
>Here it is again. If you use the html:multibox, you can get back an array
>of
>key values instead of an array of booleans. They key values can be Longs,
>Strings, whatever, as long as it uniquely identifies the row that you want
>to know was checked. If you haven't used multibox, it generates an html
>checkbox. The array that will be set in your form will only contain the key
>values for the rows that were checked.
>
>Here is the post from yesterday:
>
>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: Thursday, May 10, 2001 11:52 AM
> > To: Struts User
> > Subject: Checkbox Arrays
> >
> >
> > Can anyone help with this?
> >
> > I have an array of checkboxes in my ActionForm represented by
> >
> > boolean[] delete;
> >
> > and I have a setter function
> >
> > public void setDelete( boolean[] values )
> > {
> > delete = values;
> > }
> >
> > The problem is that I have only checkboxes that are checked
> > get sent back -
> > so if one checkbox is checked all I get is an array of length
> > 1. Therefore,
> > it is not possible for me to determine which checkbox has
> > been checked.
> >
> > In the documentation it tells me to use reset() in ActionForm
> > to initialise
> > the values - but this will only work with single checkboxes
> > and not arrays.
> >
> > I think I'm stuck. Is there anyway I can determine which
> > checkbox has been
> > checked - maybe I can get the value to differ for each
> > checkbox. Will look
> > in to that.
> >
> > Cheers
> > Tony
> >
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.