tags:

views:

28

answers:

1

I have a jsp page which loads information into various tables depending on query parameters however I want to be able to iterate through the returned lists using the tag and evaluate for each iteration if a value from the DB is == to "1" using then do result 1 else do result 2.

The code I have tried but fails to work correctly is:

<s:iterator value="#session.List" var="ObjHeader">
<tr>
 <td><s:property value="value1" /></td>
 <td><s:property value="value2" /></td>
 <td><s:property value="value3" /></td>
 <td><s:property value="value4"/></td>
       <s:if test='%{<s:property value="value4"/> == "0"}'>
 <td align="center"><a href="./edit?ID=<s:property value="value1"/>"><img
src="/img1.jpg" width="15px" height="15px"/></a></td>
 </s:if>
<s:else>
<td align="center"><img
src="/img2.jpg" width="15px" height="15px"/></td>
</s:else>
<td align="center"><a href="./readonly?id=<s:property value="value1"/>"><img
src="/img2.jpg" width="15px" height="15px"/></a></td>
</tr>
</s:iterator>

This fails to evaluate correctly and results in error.

<s:iterator value="#session.List" var="ObjHeader">
 <tr>
 <td><s:property value="value1" /></td>
 <td><s:property value="value2" /></td>
 <td><s:property value="value3" /></td>
 <td><s:property value="value4"/></td>
        <td align="center"><a href="./edit?ID=<s:property value="value1"/>"><img
src="/img1.jpg" width="15px" height="15px"/></a></td>
 <td align="center"><a href="./readonly?id=<s:property value="value1"/>"><img
src="/img2.jpg" width="15px" height="15px"/></a></td>
 </tr>
 </s:iterator>

however without the if statement it return and prints out the results fine - is it a syntax error that is preventing this or is there a bigger issue ?

+1  A: 

You cannot put a tag inside another. Try something like this

<s:if test='value4 == 0'>
leonbloy