This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Struts and the fly likes struts - how to display table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts - how to display table" Watch "struts - how to display table" New topic
Author

struts - how to display table

Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30356
    
150

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30356
    
150

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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30356
    
150

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

Joined: Dec 02, 2004
Posts: 9
-------------------------------------------------
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>


Kevin Judd, SCJP
dhana sss
Greenhorn

Joined: Dec 04, 2004
Posts: 16
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts - how to display table