Struts 1 - 行提交

发布于 2024-12-25 23:18:04 字数 1767 浏览 4 评论 0原文

我在使用 Struts 1 表单时遇到问题,该表单包含一个逻辑:迭代,负责创建行,每行都有一个输入按钮。 当我点击任何一个提交按钮时,就会出现问题,动态数据未正确发布,并且表单没有这些值,这是一个示例:

<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>

“城市”部分和逻辑之外的其余部分:迭代,在“myForm”上显示得很好,但在“myObject”上则不然。我什至尝试使用 JavaScript 函数提交此内容,但无法使其正常工作。 目前,我所拥有的(我留下作为参考的 html:submit)导致 POST 包含一堆“状态”参数和我之前提到的正确值。

有人能解释一下吗?

如果您需要更多信息,请告诉我。

预先非常感谢!

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" /> </td>
      <td class="result-cell"><bean:write name="myObject" property="name" /> </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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

寻找我们的幸福 2025-01-01 23:18:04

我没有使用单一表单,而是在逻辑:迭代中使用了一个表单,向相应的属性添加了索引,并使用 Javascript 函数来获取其余内容。

谢谢!

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!

勿忘初心 2025-01-01 23:18:04

逻辑迭代:尝试这样做可能会对您有所帮助。

<logic:iterate name="myForm" property="myObjects" id="myObjects" indexId="true">
  <tr>
   <td class="result-cell"><bean:write name="myObjects" property="id" /> </td>
      <td class="result-cell"><bean:write name="myObjects" property="name"/> </td>
      <td>
        <html:submit/>
      </td>    
  </tr>
</logic:iterate>

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" /> </td>
      <td class="result-cell"><bean:write name="myObjects" property="name"/> </td>
      <td>
        <html:submit/>
      </td>    
  </tr>
</logic:iterate>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文