Hi Rahul,

Dont't know if I can be of much help but this is what I did for displaying a
tree structure on the browser. I had used a stateless session bean wih the
DAO pattern, a stored procedure at the database and not a "JTree-like"
structure but a JTree structure instead.

If there are no implementation constraints of having a stored procedure at
the database, then go ahead and make one which will return you a resultset
in the following format
        a
        b
        d
        e
        c
        f

Use an appropriate algorithm in the business method that can create a
TreeModel by parsing the resultset and have this TreeModel returned to the
servlet which can then pass it on to the applet. The thing that you have to
worry about while using the applet is the browser-java plugin issue. The
thing that you don't have to worry about is the browser compatibility issue.

Regards,

-- Rahul



-----Original Message-----
From: Rahul Desai [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, October 17, 2001 10:24 AM
To: [EMAIL PROTECTED]
Subject: problem querying trees


Hi all,

My problem is as follows:

I have a table as follows

ID    Name      ParentId
-------------------------
1     a         NULL
2     b         1
3     c         1
4     d         2
5     e         2
6     f         3


Basically it represents a tree.I am planning to have CMP bean for this
table.On the Client(Browser), I need to show the entire tree(Just like a
JTree).I am not able to figure out the best way to do this.
The first thing that strikes me is to have a session bean queries for the
ROOT node(findByParentId(null)) first and the recursivley queries for the
child nodes (findByParentId(parentId)) and then builds some Tree
DataStructure out of these and pass it back to the servlet. I dont know if
this approach is correct because this involves lot of trips to the database.

If anybody has better solutions for this, please let me know

Thanks in advance,
Rahul Desai

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to