As a simpler alternative, you could create a custom tag handler or a JSP
2.0 tag file that knows how to render a tree node and invoke itself
recursively as necessary to render child nodes. You could even use a JSP
include and not bother with custom tags / tag files at all. As long as
you have your tree node rendering extracted into a distinct 'invocation
unit' of some form, you can get the recursive rendering you need.
L.
Richard Allwood wrote:
You can create a Iterator class that traverses the tree structure.
If you need to display the tree structure in the JSP page then the
Iterator will need to maintain enough information about depth
traversed/siblings to ensure that the tree structure can be rendered for
each value iterated through. (The best way to encapsulate this
presentation logic is to write a custom TagHandler).
Your classes would look something like:
(Iterable object for creating the iterator)
public class TreeWalker<T> implements Iterable<TreeNode<T>>
(Iterator itself - provides methods to get the Tree Node, and info on
the position within the Tree)
public interface TreeNode<T>
Cheers,
Richard.
-----Original Message-----
From: Vinit Sharma [mailto:[EMAIL PROTECTED]
Sent: Thursday, 6 April 2006 11:48 p.m.
To: Struts Users Mailing List
Subject: Tree display in JSP page
Hi,
I've a class, which looks like:
public class Tree {
private String label;
private int level;
private Tree childRef;
private Tree siblingRef;
private Tree startRef;
}
I'd like to diplay this data structure on my JSP page. Its a trick, as
recursion is not possible in JSP as compared to what we can do in a
normal class, any idea how this can be done?
Thanks,
--
Vinit Sharma
IBM
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]