Thanks very much, that was just the nudge in the right direction. I found
the http://jakarta.apache.org/struts/faqs/indexedprops.html page very
helpful. As I am using EL and the JSTL tags I found that creating a method:

public List getMedia(int index) { ... }

as that page suggested ("List-backed Indexed Properties") caused the
<c:forEach> tag to complain it couldn't find a getter for property media so
I had to create 2 methods:

public List getMedia() { 
        return media;
} 

public MediaBean getMedium(int index) {
     while(index >= media.size()) {
          media.add(new MediaBean())
     }
     return (MediaBean)media.get(index);
}

and use this in the JSP:

<c:forEach varStatus="status" var="med" items="${emailalertForm.media}">
        <tr>
                <td><fmt:message key="${med.mediaName}" /></td>
                <td><html:checkbox
property="medium[${status.index}].selected" /></td>     </tr>
</c:forEach>

to get everything to display and return correctly.

Cheers,

Ed!

-----Original Message-----
From: Nicholas L Mohler [mailto:[EMAIL PROTECTED]
Sent: 19 November 2003 12:45
To: Struts Users Mailing List
Subject: Re: Using a collection of Beans within an ActionForm

Ed,

You can find examples of this by searching the archive for indexed
properties.  

[snip]

There are a few ways to do this.  My getter method:

public CollectionBean getCollectionName(int index) {
     while(index >= collectionName.size()) {
          collectionName.add(new CollectionBean())
     }
     return (CollectionBean)collectionName.get(index);
}

Reply via email to