-1

I want to read a key and value of list from a loop. Below is the code snippet that I tried but it's not working.

<c:forEach items="${mylist}" var="title">
    <c:set var="id" value="${title.key.id}"/>
      <%Integer idInt = (Integer)pageContext.getAttribute("id");
      String idStr = "";
      if(idInt != null && idInt.intValue() > 0){
      idStr = idInt.toString();
      }%>
<s:radio theme="simple" name="selectedOption" list="#{idStr:title.value}"/>
</c:forEach>
Roman C
  • 49,761
  • 33
  • 66
  • 176
sweety
  • 105
  • 1
  • 6

1 Answers1

0

Try

<c:forEach items="${mylist}" var="title">
  <s:radio theme="simple" name="selectedOption" list="#{#attr.title.key.id:#attr.title.value}"/>
</c:forEach>

The variable title is in the page scope, but you don't need a scriptlet to access it.

Roman C
  • 49,761
  • 33
  • 66
  • 176