You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Brian Knorr <bt...@nextjet.com> on 2001/03/08 18:16:43 UTC

ugly code using iterate tag over a form with html tags

This is code looks pretty complicated and ugly, which to me defeats the
whole purpose of struts, but this is the only way I can get struts to
support dynamic input and select tags in an html form.  Does anyone know
of an easier way?  Are there plans for better support of this in the
future?

<% int count=0; %>
<logic:iterate id="notification" name="notificationForm"
property="notifications" type="com.web.model.Notification">
<tr>
  <td><input type="text" name="<%= "notifications["+(count)+"].where"
%>" value="<%= notification.getWhere() %>"/></td>
  <td>
    <select name="<%= "notifications["+(count)+"].when" %>">
      <logic:iterate id="type" name="notificationFilterTypes"
type="com.web.model.NotificationFilterType">
        <option value="<%= type.getCode() %>" <%=
(type.getCode().equals(notification.getWhen())) ? "selected" : "" %>><%=
type.getValue() %></option>
      </logic:iterate>
    </select>
  </td>
</tr>
<% count++; %>
</logic:iterate>


Thanks,

Brian