简体   繁体   English

Struts2 - 选择不在迭代器中工作

[英]Struts2 - Select not working in iterator

I have an issue with a select in an iterator. 我在迭代器中有一个select的问题。 Whenever I use the index value of my iterator status in the name property of the select, the form isn't submitting properly. 每当我在select的name属性中使用my iterator statusindex值时,表单都没有正确提交。

In my code I use a first iterator to iterate through a list of days and a second iterator to iterate through my records to display and edit their data. 在我的代码中,我使用first iterator迭代一天的日期和second iterator来遍历我的记录以显示和编辑它们的数据。

page.jsp page.jsp

<s:iterator value="daysOfWeek" var="jour" status="stat">
    <div class="gu desk-s1 desk-w2" id="plage${stat.index}">
        <s:text name="%{#jour}"/>
        <s:submit type="button" action="addPlage/%{#stat.index}">+</s:submit>
        <s:iterator value="plageRecords" var="plage" status="innserStat">
            <s:if test="%{#plage.jour == #stat.index}">
                <s:include value="plage/plage_cell.jsp"/>
            </s:if>
        </s:iterator>
    </div>
</s:iterator>

page_cell.jsp page_cell.jsp

<div class="g rev-width rev-top-m1">
    <div class="gu desk-w6">
        <label><s:text name="admin.plage.label.endHour" /></label>
        <s:fielderror class="fieldError"
                      fieldName="plageRecords[%{#innserStat.index}].heureFin"/>
    </div>
    <div class="gu desk-w10">
        <s:select name="plageRecords[%{#innserStat.index}].heureFin"
                  cssClass="rev-side-m1 rev-width" list="endHourList"/>
    </div>
</div>

You have wrong expression in the if tag: if标记中有错误的表达式:

<s:if test="%{#plage.jour == #stat.index}">

it should be 它应该是

<s:if test="%{#plage.jour == #jour}">

if expression is not evaluated or evaluated to false then select tag will never be added to the form, and the formdata will never be submitted. 如果表达式未被评估或评估为false则select标签将永远不会添加到表单中,并且将永远不会提交formdata。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM