Hello,
I have a hashtable containing timeIn, timeOut logs for an attendance system. I place a column, total no. of hours at the end of the table, however, there are times when the logs are incomplete that is, there
is only one timeIn, timeOut pair for a specific day. So I have to add
the nbsp; in my table cells so that the data for the total no. of hours
will fall under the total no. of hours table and not on the second time in
column.
Sample table
Time In Time Out Time In Time Out Time In Time Out Total Hours
7:00 18:00 3.0
---------------------------------------------------------------------------
Is there an elegant way to do this using the logic:iterate tag?
My code to do this is as follows:
<logic:iterate id="timeData" name="timeRecords">
<tr>
<logic:iterate id="log" name="timeData" property="timeLogs">
<td align="center" bgcolor="#FFFFFF" height="1" width="94">
<bean:write name="log" property="key"/>
</td>
<td align="center" bgcolor="#FFFFFF" height="1" width="94">
<bean:write name="log" property="value" />
</td>
</logic:iterate>
<!-- add a logic:iterate here to iterate over the empty table cells
-->
<td align="center" bgcolor="#FFFFFF" height="1" width="94">
<bean:write name="timeData" property="totalWorkTime"/>
</td>
</tr>
</logic:iterate>
I assumed that each entry is complete and there are no blank entries. I've thought of adding an offset variable in my bean so that I can add the nbsp; for the empty table cells accordingly but I find this to be too cumbersome. Any ideas on how to fill those empty cells using logic:iterate? The problem I encountered when I tried using logic:iterate to fill in the blank cells is that logic:iterate needs a collection to iterate over, in this case, no collection is obviously needed, it just needs to iterate over the parts where there are no time log entries.
Thank you very much.