Hello,
I have a Collection that I'd like to iterate over and display using Struts.
I've been unsuccessful to this point and I'm in hopes someone can tell me
what's wrong.
This works for populating a select list with values from the collection:
<% Collection songs = SongCache.getInstance().fetchAll(); %>
<html:select property="id">
<%
Iterator iterator = songs.iterator();
while (iterator.hasNext()) {
Song song = (Song)iterator.next();
%>
<html:option value="<%= song.getStringId() %>">
<%= song.getName() %>
</html:option>
<%
} // while
%>
</html:select>
This is what I'm trying and does not work. Any clues?
<% Collection songs = SongCache.getInstance().fetchAll(); %>
<html:select property="id">
<logic:iterate id="element" name="songs" type="com.mycompany.Song">
<html:option value="<bean:write name="element" property="stringId"/>">
<bean:write name="element" property="name"/>
</html:option>
</logic:iterate>
</html:select>
I get the error:
org.apache.jasper.compiler.ParseException: Attribute element has no value
Also, does anyone know how to convert:
<% Collection songs = SongCache.getInstance().fetchAll(); %>
into a <bean:define>? After reading the documentation it doesn't seem
possible. songs can't be set with request.setAttribute() b/c this page is
loaded via a hyperlink that doesn't go through an Action.
Thanks in advance.
-ryan
PS. Struts 1.0 on JBoss 2.2.2 w/embedded Tomcat 3.2.2