<[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I have one form bean namely "MyFormBean".
> This bean contain vector (pricesVector) of class type "Price".
>
> The class Price has two attribute "oldPrice" and "newPrice"
>
> I want to display prices vector in such fashion
>
> ---------------------------------------------------------------------
> oldprice1 (as label) newPrice1 (in text box)
> oldprice2 (as label) newPrice2 (in text box)
> oldprice2 (as label) newPrice2 (in text box)
> ---------------------------------------------------------------------
>
> How do I do this using iterate tag, so that any updation in text box should
> get updated in the vector (prices)?
> I tried using iterate tag but could not get through?
>
> Anybody having solution for this.
1) You have to have two properties in your ActionForm:
public Collection getPrices();
and
public Price getPrice(int i);
Note: getPrice() should return valid Price even if the Vector does not
contain it.
it could look something like this:
public Price getPrice(int i) {
while (pricesVector.size() <= i) {
pricesVector.add(new Price());
}
return pricesVector.get(i);
}
2)
your iterate tag could look something like this:
<logic:iterate
name="editPricesForm" property="prices"
id="element" indexId="i"
type="Price">
<tr>
<td><bean:write name="element" property="oldPrice" /></td>
<td><html:text property='<%= "price[" + i + "].newPrice" %>' />
<html:hidden property='<%= "price[" + i + "].productID" %>' />
</td>
</tr>
</logic:iterate>
You have to know, that the Vector will be FILLED (not just updated) when the
form is submitted.
--
gR