You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ted Bergeron <te...@websidestory.com> on 2001/03/01 02:28:03 UTC
Form tags
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>
RE: Form tags
Posted by Ted Bergeron <te...@websidestory.com>.
Does anyone have any ideas about this?
-----Original Message-----
From: Brian Knorr [mailto:btk@nextjet.com]
Sent: Tuesday, March 06, 2001 12:16 PM
To: ted@websidestory.com
Subject: struts -- Form tags
Ted,
Hi... I was wondering if you ever heard anything back from the struts user
group on the "Form tags" issue you posted? I was wondering the exact same
thing... especially for radio buttons.
Thanks,
Brian Knorr
NextJet! the leader in same day delivery.
-----Original Message-----
From: Ted Bergeron [mailto:ted@websidestory.com]
Sent: Wednesday, February 28, 2001 5:28 PM
To: Struts-User
Subject: Form tags
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>