Pergunta

I'm having an issue with a Struts 1 form, which contains a logic:iterate in charge of creating rows, each with an input button. The problem comes up when I hit any of those submit buttons, the dynamic data is not properly being posted and the form doesn't have those values, here's an example:

<html:form action="/myAction" styleClass="centeredForm"  style="display:inline" >
  <td class="formLabel">City</td>
  <td class="formControl">
    <bean:define id="cities" name="myForm"
                 property="cities" type="java.util.Collection"/>
    <html:select styleClass="dashSelect" property="city">
      <html:option value="">All Cities</html:option>
      <html:options collection="cities"
                    property="id" labelProperty="value"/>
    </html:select>
  </td>

  ... Other elements ...

  <logic:iterate id="myObject" name="myForm" property="myObjects" indexId="index" type="com.test.MyObject">
      <% String rowClass = index.intValue() % 2 == 0 ? "even-row" : "odd-row"; %>
    <tr class="<%=rowClass%>">
      <td class="result-cell"><bean:write name="myObject" property="id" />&nbsp;</td>
      <td class="result-cell"><bean:write name="myObject" property="name" />&nbsp;</td>
      <td class="result-cell">
        <html:select styleClass="dashSelect" name="myObject" property="status">
          <html:option value="F">Disabled</html:option>
          <html:option value="T">Enabled</html:option>
        </html:select>
      </td>

      <td>
        <html:submit/>
      </td>

The "city" portion and the rest outside of the logic:iterate, come up just fine on "myForm", but "myObject" isn't. I even tried submitting this with a JavaScript function but wasn't able to get it properly working. Currently, what I have (That html:submit that I left as a reference) causes the POST to contain a bunch of "status" parameters and the proper values that I mentioned before.

Can anyone shed some light onto this?

Let me know if you need further information.

Thanks a lot in advance!

Foi útil?

Solução

Instead of using one single form, I've just used a form inside the logic:iterate, added indexes to the corresponding properties and used a Javascript function to obtain the rest.

Thanks!

Outras dicas

Logic Iterate: Try do this way It may be help you.

<logic:iterate name="myForm" property="myObjects" id="myObjects" indexId="true">
  <tr>
   <td class="result-cell"><bean:write name="myObjects" property="id" />&nbsp;</td>
      <td class="result-cell"><bean:write name="myObjects" property="name"/>&nbsp;</td>
      <td>
        <html:submit/>
      </td>    
  </tr>
</logic:iterate>
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top