You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Doug Dates <hi...@yahoo.ca> on 2002/09/15 18:30:16 UTC
How to populate a collection to ActionForm
Hello:
I encountered a problem now. I appreciate your help.
In my action class, I got a collection of payments(Type of Vector). I want to populate the payments to my actionForm. The following is what I did in action class:
if (!payments.isEmpty()) {
myForm.setPayments(payments); //In myForm, I defined getPayments() and setPayments(..) methods.
}
Also, I want to display the amount of individule payment of the collection. I think I should use iterate tag. The following is the part of my Jsp:
<logic:iterate id="payment" name="payments">
<bean:write name="payment" property="amount">
</logic:iterate>
Is there something wrong with the code? Please help me.
Thanks.
Doug
RE: How to populate a collection to ActionForm
Posted by Robert Taylor <rt...@mulework.com>.
Doug,
The name attribute in the logic:iterate tag identifies
the object which contains your collection. Since your form
contains your collection the name attribute value should be
your form name. Try the following:
<logic:iterate id="payment" name="formName" property="payments">
<bean:write name="payment" property="amount">
</logic:iterate>
robert
> -----Original Message-----
> From: Doug Dates [mailto:hinbsls@yahoo.ca]
> Sent: Sunday, September 15, 2002 12:30 PM
> To: Struts Users Mailing List
> Subject: How to populate a collection to ActionForm
>
>
> Hello:
>
> I encountered a problem now. I appreciate your help.
>
> In my action class, I got a collection of payments(Type of
> Vector). I want to populate the payments to my actionForm. The
> following is what I did in action class:
>
> if (!payments.isEmpty()) {
> myForm.setPayments(payments); //In myForm, I defined
> getPayments() and setPayments(..) methods.
> }
>
> Also, I want to display the amount of individule payment of the
> collection. I think I should use iterate tag. The following is
> the part of my Jsp:
>
> <logic:iterate id="payment" name="payments">
> <bean:write name="payment" property="amount">
> </logic:iterate>
>
> Is there something wrong with the code? Please help me.
> Thanks.
>
> Doug
>
>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>