Brad,
Is the RowsForm a session-scoped ActionForm? If it is request-scope, you can
be sure that they are being set on the submit, rather than hanging around in
the session.
The setRows() method was intended to be used in the Action that gets the
Vector of data from the DB (or elsewhere) to copy the data into the arrays,
which would then be copied into RowForm objects when the <logic:iterate> tag
calls getRows() and iterates over the Collection of RowForm objects to
display. Or you could skip the bean-array-bean copying, and just hold a
reference (a member variable on RowsForm) so that you can set the row data,
and then if the member variable is already holding a Collection, just return
that from getRows(), instead of copying the data from the arrays to a
collection of new beans. Be sure to null the collection reference when
reset() is called. Something like this:
public class RowsForm extends ActionForm {
private Collection rows = null;
public void reset(ActionMapping mapping, HttpServletRequest request) {
rows = null; }
public void setRows(Collection rows) { this.rows = rows; }
public Collection getRows() {
if (rows == null) {
rows = new ArrayList();
// copy array data into new RowForm objects, adding each one to the
Collection
}
return rows;
}
}
On submit, Struts will call setRowId() with a String array of values
submitted in the HTTP request. HTTP only supports named fields(like "rowId"
and "rowProperty1") that can have multiple values. For each field name,
Struts creates a String array of the values that were submitted for that
field name, and sets the property on your RowsForm accordingly. HTTP doesn't
support more complicated structures like row objects that each have an Id
and Property1 property, so you won't get a call to setRows(). Ted Husted has
a decription of how this works that is worth a read to understand what is
happening: http://www.husted.com/struts/tips/006.html
The amount of copying has always bothered me, but it seemed to do what I
wanted, so I decided to just live with the excessive copying until I learned
a better way. However, V. Cekvenich's post about indexed properties sounds
like it gets around this problem more elegantly and efficiently, so I'm
going to try to convert one of my pages to this scheme and see how it works.
I'll post a similar example as soon as I work it out. Does anyone know the
URL of the indexed properties FAQ? The link on this page is broken:
http://jakarta.apache.org/struts/userGuide/building_view.html#indexed
Here is something along those lines:
http://www.jguru.com/faq/view.jsp?EID=993534
-Max
----- Original Message -----
From: "Brad Balmer" <[EMAIL PROTECTED]>
To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
Sent: Thursday, December 12, 2002 10:30 AM
Subject: RE: Processing multiple records all at once
> OK,
>
> This makes perfect sense to me and pretty much has worked, but I don't
> get the changes I make to the form data.
>
> I have the following in my Action class.
>
> RowsForm rForm = (RowsForm)form;
> Vector data = rForm.getRows();
> for(int i=0; i<data.size(); i++)
> {
> RowBean bean = (RowBean)data.get(i);
> log.debug("ID: " + bean.getId() +
> " - PROPERTY: " + bean.getProperty1());
> }
>
> When I make a change to the property1 property on the jsp and click
> Submit, I STILL get the original values for all of the RowBean beans
> that I originally placed in the form.
>
> I tried implementing a setRows function, but it was never called. I
> guess I don't understand how the updated values are set into the
> variables on submit.
>
>
(SNIP)
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>