Rémi Hirtz
Rémi Hirtz

Reputation: 103

Why s:select not working in s:iterator tag?

I have an issue with a select in an iterator. Whenever I use the index value of my iterator status in the name property of the select, the form isn't submitting properly.

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.

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:

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

Upvotes: 3

Views: 474

Answers (1)

Roman C
Roman C

Reputation: 1

You have wrong expression in the if tag:

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

Upvotes: 1

Related Questions