• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

struts - how to display table

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34860
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to display a table that looks something like this:

I'd like to do this using Struts tags without using nested tables (because some user agents have difficulty with nested tables.) Any ideas in how to do this using Struts?

Two approaches I thought of:
1) I know how to do this if I know the # of grouped rows when I read each one. For example if I know there are two grouped rows, I can set the colspan to two. Do I need some kind of custom iterator to get access to this information?

2) Another way would be to store the data in a nested data structure. Then I could get the size of the nested list. But I'd need to get the first nested value separate from the rest of them.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34860
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry about the poor ASCII art. When I hit refresh, it displays properly. If the table doesn't display, the gist of it is that there a single account can have several rows of values. But the account # amd amount span all of those rows.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34860
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it. I need to create the a custom data structure that can return the rowspan, the first nested row and a collection of all the other nested rows. Then, I can use Struts tags and keep code out of my JSP.
 
Kevin Judd
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
-------------------------------------------------
Instead of using rowspan, you could also iterate over the data elements in account#1, field#1 and enter a <br /> after each. One advantage to this is that it would work for a variable number of elements.

e.g.
<tr>
<td>account #1<td>
<td>a<br />c</td>
<td>b<br />d<td>
<td>555.00</td>
</tr>
 
dhana sss
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai friend i dono much about this. try this one

<TABLE class="normtext" id="Table5" style="WIDTH: 688px; HEIGHT: 26px" cellSpacing="0"
cellPadding="0" width="688" border="0">

<TR align="left" bgcolor="lightsteelblue">
<TH>Prefix</TH><TH>First Name</TH><TH>Last Name</TH>
<TH>Office Phone</TH><TH>Mobile Number</TH><TH>Address</TH>
<TH>City</TH><TH>Country</TH><TH>Zip Code</TH>
</TR >
<%! int count=0;%>
<logic:iterate id="customer" name="customers">
<%
count=count+1;
%>

<tr align="left" bgColor="#f0f8ff">
<td>
<bean:write name="customer" property="prefix" />
</td>
<td>
<bean:write name="customer" property="fname" />
</td>
<td>
<bean:write name="customer" property="lname" />
</td>
<td>
<bean:write name="customer" property="ophone" />
</td>
<td>
<bean:write name="customer" property="mnumber" />
</td>
<td>
<bean:write name="customer" property="address" />
</td>
<td>
<bean:write name="customer" property="city" />
</td>
<td>
<bean:write name="customer" property="country" />
</td>
<td>
<bean:write name="customer" property="zipcode" />
</td>
</logic:iterate>
</tr>
</TABLE>
<%
if (count!= 0)
{ %>

by
dhana
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic