2

I need to generate unique id attributes within the struts iterator on the lines of

<div id="divId1"/>
<div id="divId2"/>
 etc, etc.

I've tried

<s:iterator value="myListFunction" status="#status">
    <s:set var="uniqueId" value="divId#status.count/>
    <s:div id="%{uniqueId}/>
</s:iterator>

and variations of the above, but nothing seems to work. Could someone point me in the right direction please

user497087
  • 1,561
  • 3
  • 24
  • 41

2 Answers2

4

Try this:

<s:iterator value="myListFunction" status="status">
    <s:div id="divId%{#status.count}/>
</s:iterator>
Jay
  • 86
  • 2
  • Apart from the "deliberate" mistake (it's status.index not status.count (Doh!!)), this works provided I place the evaluation on the – user497087 Feb 24 '11 at 08:31
  • Thanks for this! I was using materializecss dropdown with struts iterator and i wanted a unique id for each of the dropdowns generated. This method worked BIG time! Thankyou very much! – hulkinBrain Jun 08 '16 at 18:22
0

Did you try (not tested):

<s:iterator value="myListFunction" status="status">
  <s:div id='%{"divId" + #status.count}'/>
</s:iterator>
Quaternion
  • 10,380
  • 6
  • 51
  • 102