Menu
Struts 2 > Struts 2 If and Else Tags Example

Struts 2 If and Else Tags Example

We use the if and else tags to highlight the even and odd rows in different colors. We use the IteratorStatus class methods to find whether the row is even or odd. The following code shows how to do this.

<s:iterator value="songs" status="songStatus">
<tr
class="<s:if test="#songStatus.odd == true ">odd</s:if><s:else>even</s:else>">
<td><s:property value="title" /></td>
<td><s:property value="genre" /></td>
</tr>
</s:iterator>

The elseif tag is also available. You can use it if there are multiple conditions to check.

You can download the Struts 2 Control Tags Example by clicking the Download link below.

Source :Download
Source + Lib :Download
Subscribe
Contact Us  |  Copyright © 2009 vaannila.com