• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

struts - how to display table

 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic