Name:
Location: Bangalore, India

Monday, October 22, 2007

To iterate a list in JSP Page

<logic:present name="RequestForm" property="objSearchResultsList">
<logic:notEmpty name="RequestForm" property="objSearchResultsList">
<logic:iterate id="row" name="RequestForm" property="objSearchResultsList">
<tr>
<td> <bean:write name="row" property='bankName' /></td>
<td> <bean:write name="row" property='requestAmount' /></td>
</tr>
</logic:iterate>
</logic:notEmpty>
</logic:present>

Here we don’t have the tag bean:define to define the bean and then iterate since we are directly iterating using logic:iterate.

The id attribute in logic:iterate points to the bean objects inside the list with which you can iterate. We will be using the value of id attribute in logic:iterate as the value of name attribute in bean:write.


The id attribute specifies a scriptlet variable that is assigned the current item at the start of each iteration, namely employee.

<logic:iterate id="element"
name="bean"
property="stringArray"
indexId="index">


The indexId attribute specifies a scriptlet variable called index, which holds that current index number of the loop. This is useful if you want to generate row numbers for long listings.

0 Comments:

Post a Comment

<< Home