To get struts to auto-populate the changes on submit, you have to use indexed
tags (either nightly build, or via scriplets) and add to your form bean a getter
to get a single object from the collection.
Cheers,
Dave
Andrew van der Voort <[EMAIL PROTECTED]> on 10/23/2001
12:22:22 AM
Please respond to [EMAIL PROTECTED]
To: "'[EMAIL PROTECTED]'"
<[EMAIL PROTECTED]>
cc: (bcc: David Hay/Lex/Lexmark)
Subject: RE: Iterate with 3 array lists (urgent)
What I have done (and seems to work) is:
My ActionForm (I've taken out a lot of erroneous stuff for this
conversation):
public class ViewOutputClassListForm extends ActionForm implements
java.io.Serializable
{
private Collection outputClassList;
private String[] pctAllocations;
public ViewOutputClassListForm()
{
}
public void setPctAllocation( String[] allocations )
{
this.pctAllocations = allocations;
}
public Collection getOutputClassList()
{
return this.outputClassList;
}
public void setOutputClassList( Collection outputClassList )
{
this.outputClassList = outputClassList;
}
}
The outputClassList contains a bunch of OutputClassDto objects. One of
the attributes is pctAllocation, with matching get and set methods.
My jsp page:
<logic:iterate id="element" name="ViewOutputClassListForm"
property="outputClassList" indexId="index" scope="session"
type="myPackageName.OutputClassDto">
<TR>
<TD><bean:write name="element" property="name"/></TD>
<TD><format:format name="element" property="budget" purpose="View"
type="Currency"/></TD>
<TD><format:text name="element" property="pctAllocation"
purpose="Edit" type="Numeric" /></TD>
</TR>
</logic:iterate>
Note that the purpose and type properties are extensions that we added
so that numbers can be formatted how we want. Ignore those.
In the validate() method of the form, after it has been submitted,
attribute pctAllocations is populated with an array of the values for
property pctAllocation.
It would have been better for the individual objects in outputClassList
to have had their set methods called to update the data but it wasn't,
and this seems to work.
Andrew