| Author |
logic:iterate
|
Leo Lim
Greenhorn
Joined: Apr 25, 2004
Posts: 5
|
|
Hello, I'm new to Struts and would like to ask for someone's help explaining the behavior of the logic:iterate tag. I used the logic:iterate tag to display the contents of an ArrayList which are objects that contain a Hashtable which I display using another logic:iterate tag. However, when I tried to view the source after displaying the page, the outer </logic:iterate> tag seemed to be ignored, both the outer logic:iterate and the inner logic:iterate tags terminated when it encountered the closing inner </logic:iterate> tag. I used Tomcat 4 for this. Here is a snippet of my code: Note: "timeRecords" is an attribute I set in my session. <logic:notEmpty name="timeRecords"> <table border="4"> <th> <bean:message key="timeRecord.date"/> </th> <th> <bean:message key="timeRecord.timeIn"/> </th> <th> <bean:message key="timeRecord.timeOut"/> </th> <th> <bean:message key="timeRecord.timeIn"/> </th> <th> <bean:message key="timeRecord.timeOut"/> </th> <th> <bean:message key="timeRecord.timeIn"/> </th> <th> <bean:message key="timeRecord.timeOut"/> </th> <th> <bean:message key="timeRecord.totalWorkHours"/> </th> <logic:iterate id="timeData" name="timeRecords"> <tr> <td> <bean:write name="timeData" property="date"/> </td> <logic:iterate id="log" name="timeData" property="timeLogs"/> <td> <bean:write name="log" property="key"/> </td> <td> <bean:write name="log" property="value"/> </td> </logic:iterate> </tr> </logic:iterate> </table> </logic:notEmpty> Source after loading the page. <snip> <table border="4"> <th> Date </th> <th> Time In </th> <th> Time Out </th> <th> Time In </th> <th> Time Out </th> <th> Time In </th> <th> Time Out </th> <th> Total No. of Working Hours </th> <tr> <td> 2004-04-20 </td> <td> 18:00:00 </td> <td> 22:00:00 </td> -----> a closing </tr> should have been found here <tr> <td> 2004-04-21 </td> <td> 08:00:00 </td> <td> 18:00:00 </td> </tr> </logic:iterate> -->This is the unparsed closing /logic:iterate </table> </body> </html> Any ideas as to what I am doing wrong? Thank you very much.
|
 |
Qi Liang
Greenhorn
Joined: Jun 04, 2003
Posts: 28
|
|
|
The outer <logic:iterate> matches the first </logic:iterate>, which seems a bug in struts!
|
 |
Leo Lim
Greenhorn
Joined: Apr 25, 2004
Posts: 5
|
|
I just solved the problem now, the inner logic:iterate contains a "/" at the end which makes it an invalid logic:iterate tag. Thus, when the server renders the page, the outer logic:iterate treats the closing inner logic:iterate as its closing tag instead of the outer logic:iterate tag which is why the outer logic:iterate tag is ignored and the closing </tr> is ignored as well as the outer loop reiterates as it encounters the inner logic:iterate tag. Thanks for all the help though. <logic:iterate id="timeData" name="timeRecords"> <tr> <td> <bean:write name="timeData" property="date"/> </td> <logic:iterate id="log" name="timeData" property="timeLogs"/> ^^^^ <td> <bean:write name="log" property="key"/> </td> <td> <bean:write name="log" property="value"/> </td> </logic:iterate> </tr> </logic:iterate>
|
 |
 |
|
|
subject: logic:iterate
|
|
|