I'm wondering about the logic behind the form tags. Here I have a simple
form that is created by iterating over a collection. The iterator exposes
the variable "item" which is a String for this simple case. The name
attribute of bean:write treats "item" as a variable, while the value
attribute of various form tags (radio, text, hidden) treats "item" as a
literal. Thus, the "<%= item %>" workaround. This workaround leads to code
that is not well formed xml, and becomes much uglier with a collection of
complex objects.
Am I using the framework incorrectly? Is this an oversight/bug? Is this a
necessary behavior?
Thanks for the help,
Ted
<% java.util.ArrayList list = new java.util.ArrayList();
list.add("First");
list.add("Second");
list.add("Third");
list.add("Fourth");
list.add("Fifth");
pageContext.setAttribute("list", list, PageContext.PAGE_SCOPE);
%>
<html:form action="/test.do">
<table>
<logic:iterate id="item" name="list" type="java.lang.String">
<tr>
<td><html:radio property="username" value="item"/></td>
<td><html:radio property="username" value="<%= item %>"/></td>
<td><bean:write name="item"/></td>
</tr>
</logic:iterate>
</table>
</html:form>