Wednesday, April 29, 2020

[Struts][Example] Iterator get data from List

Suppose you have a source with DataType List<Equip> named equipStatusList.and there are some field named "code" and "description".
This is an example of the struts iterator used in view with Spring framework:
<s:iterator value="equipStatusList" status="statusTitle">
  <div onclick="javascript:toggleSort('${equipStatusList[statusTitle.index].code}')">
    <s:property value="equipStatusList[#statusTitle.index].desciption" />
    <s:if test="%{sortBy[0]==equipStatusList[#statusTitle.index].code}">
      <s:if test='%{sortOrder=="asc"}'>
        &uArr;
      </s:if>
      <s:else>
        &dArr;
      </s:else>
    </s:if>
  </div>
</s:iterator>
index is used for get index of each iterator item.
and than use this index number to access your List item.

Reference:

https://struts.apache.org/tag-developers/iterator-tag.html

No comments :

Post a Comment