struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject RE: Displaying recursively defined bean...
Date Tue, 19 Feb 2002 20:22:18 GMT
I've done this recently for a calculation tree. I just defined a method 
in the jsp, passing in the Message (in your example) and the JSPWriter. 
This method then recursively calls itself while outputting nested html 
tables (ie each call draws a table, with the child call filling a cell 
of it).

-----Original Message-----
From: alex.paransky 
Sent: 19 February 2002 20:12
To: struts-user
Cc: alex.paransky
Subject: Displaying recursively defined bean...

I need to display a recursively defined data structure bean.

I have a bean which looks like this:

public class Message implements {
  private String header, body, from;
  private Collection replies;

  public Collection getReplies() {return collection;}
  public String getHeader() {return header;}

As you have guessed, the replies is a collection containing a Message 

So, what I want to do is start at the top message (root), and navigate 
through the replies.  For each reply, I need to "recurse" into that 
and do the same thing.  How can this be done with JSP, or Struts?  I was
thinking of using the "nested" extension, but that does not work with a
dynamic <jsp:include which is what required in this case.

The other option is to use the pageContext as a stack for the current 
and pass the new Message root in a request, something like this:

1. Read the root Message
2. Place root message into Request with name of "message"
3. <jsp:include page="display.jsp"

1. Assume there exists an object in request called "message" of type 
2. Display the details of the message
3. Iterate over message.getReplies()
4. For each object in the iteration
   a. Put the object into request with the name of "message"
   b. <jsp:include page="display.jsp"

Has any one done recursive displays using JSP?


To unsubscribe, e-mail:   
For additional commands, e-mail: 

Visit our website at

This message contains confidential information and is intended only 
for the individual named.  If you are not the named addressee you 
should not disseminate, distribute or copy this e-mail.  Please 
notify the sender immediately by e-mail if you have received this 
e-mail by mistake and delete this e-mail from your system.

E-mail transmission cannot be guaranteed to be secure or error-free 
as information could be intercepted, corrupted, lost, destroyed, 
arrive late or incomplete, or contain viruses.  The sender therefore 
does not accept liability for any errors or omissions in the contents 
of this message which arise as a result of e-mail transmission.  If 
verification is required please request a hard-copy version.  This 
message is provided for informational purposes and should not be 
construed as a solicitation or offer to buy or sell any securities or 
related financial instruments.

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message