7

I have a list of Strings that are attribute names and a Map. I'm trying to access a model(ex.project) in the map using attribute name in string list.

Here is what I have now.

<s:iterator value="theMap" var="element">
  <tr>
    <s:iterator value="attributeList" var="attrName">
      <td><p><s:property value="#element.Project.#attrName" /></p></td>
    </s:iterator>
  </tr>
</s:iterator>

If I hard code the attribute name it works fine:

<td><p><s:property value="#element.Project.projectName" /></p></td>

Any advice is appreciated.

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
Daniel Kim
  • 446
  • 2
  • 8
  • 17

1 Answers1

4

Using OGNL <s:property value="#element.Project[#attrName]" />

Aleksandr M
  • 24,264
  • 12
  • 69
  • 143