Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JSP/HTML Struts Iterate logic

Status
Not open for further replies.

james777

Programmer
Jul 9, 2000
41
0
0
US
I am currently learning Sturts/JSP.

Could someone help me by posting a piece of code to display JSP/HTML data in Struts as below.
I have a form bean and databean. I was able to use the Sturts logic tld to display the data.
The problem i am facing was , all the records were displayed ,But i need to display one column attribute once and rest of columns in a grid.

Basically i need the manager name to be displayed only once in one tab and the rest of the data in a grid.
How do i achieve this in JSP/HTML when the data is in List.



++++++++++++++++++++++++++++++++++++++++++++++++++++++
Manager Name SCOTT

Employee No Employee Name Dept No Dept Name

1234 JIM 10 HR
2345 MIKE 20 AO
2341 ROGER 10 HR
+++++++++++++++++++++++++++++++++++++++++++++++++++++++




<HTML>
<TABLE id=content-margins width="98%">
<TBODY>
<TR>
<TD colspan="2"><table id=content-margins width="98%">
<tr>
<td colspan="4"><p><strong>Manager Data </strong></p>

<logic:present name="TestForm">
<logic:present name="TestForm" property="results">
<logic:equal name="TestForm" property="results.empty" value="false">

<% System.out.println("In jsp/html 1"); %>

<table id=FormattedTable width="75%">
<tbody>
<tr class=head3>
<TH class=data-center>Manager Name</TH>
<TH class=data-center>Employee No</TH>
<TH class=data-center>Employee Name</TH>
<TH class=data-center>Dept No</TH>
<TH class=data-center>Dept Name</TH>
</tr>

<% System.out.println("In jsp/html 2"); %>

<logic:iterate id="EMPD" type="com.man.dev.action.empData"
name="TestForm" property="results">

<% System.out.println("In jsp/html 3"); %>

<tr>
<td><bean:write name="EMPD" property="managername"/></td>
<td><bean:write name="EMPD" property="empno"/></td>
<td><bean:write name="EMPD" property="empname"/></td>
<td><bean:write name="EMPD" property="deptno"/></td>
<td><bean:write name="EMPD" property="deptname"/></td>
</tr>

</logic:iterate>

</tbody>
</table>

</logic:present>
</logic:present>
</td>
</tr>

</TD
</TR>
</TABLE>
</BODY>
</HTML>


Thanks
Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top