0

I am running into an interesting problem and I can't really figure out what it is.

I have a a struts iterator that display a textfield. Defined like so:

    <s:form action="AddSubmit" method="post" theme="simple">
        <s:iterator status="rowStatus" value="otherList">
                <div>
                   <span>Input Value:</span>
                   <s:textfield theme="simple" 
                        name="valueMap[%{#rowStatus.index} + '-custom'].inputValue"/>
                                    </div>
        </s:iterator>
        <s:submit value="Save" theme="simple" />
   </s:form>

When I submit, the iterator value %{#rowStatus.index} does not evaluate to anything and the value is never set, but when I hardcode a key like 0, it works. Any idea on what is going on?

Seephor
  • 1,692
  • 3
  • 28
  • 50

1 Answers1

1

This should work:

name="%{'valueMap[\\'' + #rowStatus.index + '-custom\\'].inputValue'}"

%{ OGNL expression } is used to force OGNL evaluation of an attribute that would normally be interpreted as a String literal.

Yasser Zamani
  • 2,380
  • 21
  • 18