Tuesday, April 28, 2020

[Struts][Example] Iterator get data from array

You can use <s:property> assess items of Iterator,
or use .index to know the index for assisting get the item value.
Here is an example supposing you have a source with DataType int[] array named statusCounts.
<s:iterator value="statusCounts" status="count">
  <s:if test='%{statusCounts[#count.index]>0}'>
    <s:property>
  </s:if>
  <s:else>
    &nbsp;
  </s:else>
</s:iterator>
Reference:
https://struts.apache.org/tag-developers/iterator-tag.html
https://stackoverflow.com/questions/19856296/to-access-the-index-value-of-struts-iterator-in-scriptlet-array-index

No comments:

Post a Comment