Collection binding

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Collection binding

Maxence Dewil
This post was updated on .
Hi,

in my form I have a collection of beans, each one holding an integer.

In my JSP:

<s:property value="myIntegerList[0].value" />,<s:property value="myIntegerList[1].value" />,

Prints 1,2,

<s:iterator value="myIntegerList">
  <s:property value="value" />,
</s:iterator>

Prints 1,2,

However, when the validation has failed, for example if the user submitted 'a' instead of '2', then:

<s:property value="myIntegerList[0].value" />,<s:property value="myIntegerList[1].value" />,

Prints 1,a,

<s:iterator value="myIntegerList">
  <s:property value="value" />,
</s:iterator>

Prints 1,,

So my question is: what can I do to iterate over all the values, even the invalid ones ?

Thank you
Reply | Threaded
Open this post in threaded view
|

Re: Collection binding

Maxence Dewil
Ok, I just found a solution:

<s:iterator value="myIntegerList" status="iteratorStatus">
  <s:text name="%{'myIntegerList[' + #iteratorStatus.index + '].value'}"/>,
</s:iterator>

But this feels a bit hacky to me ;-)