Leo Lim

Greenhorn
+ Follow
since Apr 25, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Leo Lim

Hello,

I'm currently having problems figuring out how to sort table data based on the value of an html select box i.e. if the user selects a new value in the selection box, the table data below would be updated. Is there any way to do this using struts or should I use javascript instead?

Thank you very much for all your help.

Leo
20 years ago
Hi,

I know that it is not a good practice to include html markups in a property file but is there another elegant way to do otherwise?

My error message in the property file is as follows:

error.sessionExpired=Your session has expired. Please <a href="login.jsp">relogin</a>.

Is there another way to go around placing html tags in the resource file value itself using some struts feature?

Thanks.
20 years ago
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.
20 years ago
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>
20 years ago
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.
20 years ago