scanE
scanE

Reputation: 342

Dynamically assign id to tr tag using struts2

I have an ArrayList of firms with firmId, firmName,address,phoneNumber,status fields. I want to dynamically assign firmId to each row.

<s:iterator value="firms">
<tr>

    <td align="left" class="Edit">
        <img src="../images/btn-edit.png" title="Edit" width="27" height="25" alt='Edit' />
    </td>
    <td align="left"><s:property value="firmName" /></td>
    <td align="left"><s:property value="address" /></td>
    <td align="left"><s:property value="phoneNumber" /></td>
    <td align="left"><s:property value="status" /></td>

</tr>

</s:iterator>

How can I achieve this?

Upvotes: 2

Views: 2023

Answers (1)

Dave Newton
Dave Newton

Reputation: 160191

The same way you access any other property:

<s:iterator value="firms">
  <tr id="firm-<s:property value='firmId'/>">

Note that a numeric id is not a valid id, you should prepend a string constant as shown.

Upvotes: 5

Related Questions