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.