Help Needed Urgently
I want to display the Tree hierarchy using Java
.The relationship between the parent and child group is retrieved from the database.
please best way to suggest best way to display tree on UI
Jtrees cant be used at present .
i have tried using html in servlets it works to some extend ..but how to diaply the childs at the same level in a loop as teher can be one child or more then one child at the same level.
Eagarly waiting fo reply
[474 byte] By [
Akritia] at [2007-11-27 5:20:13]

> I want to display the Tree hierarchy using Java
> .The relationship between the parent and child group
> is retrieved from the database.
> please best way to suggest best way to display tree
> on UI
> Jtrees cant be used at present .
Why not?
> i have tried using html in servlets
I see.
So... you really have no clue what you're doing? I mean this UI is a
webpage is it?
> yes it is webpage .Well then a HTML and/or JavaScript forum is what you need.
can you please give me the link of forum where i can post my query as i am new to this forum
> can you please give me the link of forum where i> can post my query as i am new to this forumI think it would be better if you stated more clearly what you have tried thus far.
In the database values are as follows:
ParentGroup ChildGroup
G1G2
G2G3
G2G4
G3G5
G3G6
G4 G7
I am able to retrive these in recordset using CONNECT BY PRIOR clause in Oracle and .now i want to display them on browser using java servlet. was able to display
G1
-- G2
G3
--G5
Problem is how to display different childs of the parent at the same level , as the child can also have one or more subchilds at the next same level.
how to loop through these and display them dynamically on UI
Now I'm very confused. What exactly is the problem here? You don't know how to process the database results in the servlet? Or you don'tknow how to display them?
dont know how to display them
The problem already begins with the servlet being a controller, not a view, and the OP should use JSP for output.
It continues with the fact that the OP can't distinguish between Java and HTML, and doesn't see that it might be best if he first got clear about what his final HTML code is supposed to look like, before wondering how he can use Java to produce it.
And the keyword the OP is looking for is "recursion".
At least that's my perception.
> And the keyword the OP is looking for is> "recursion".> But what if he wants to do it dynamically?
> dont know how to display them
Akriti,
Then you need find an HTML forum so that you can decide what the HTML output is supposed to be. You need to work backwards from that point. What code you need in the servlet does not appear to be relevent at this juncture.
http://www.google.com/search?hl=en&q=HTML+forum&meta=
we have created buffer and putting html tags in it and then displaying the html tables with hierarchy data on screen.problem is the logic of loops used to display the tree nodes as tables.
> problem is the logic of loops used to
> display the tree nodes as tables.
Did I mention recursion?
printNode(Node n, int depth)
print node n with "depth" indents
if n hasChildren
-- for each child: printNode(child, depth+1)
You'll need to pass the PrintWriter (I told you to use a JSP, didn't I?) for output too, though.
> we have created buffer and putting html tags in it> and then displaying the html tables with hierarchy> data on screen.problem is the logic of loops used to> display the tree nodes as tables.Please direct yourself at reply #9.
we not using jsp instead converting buffer to string and then just displaying it. .is there any other way then recursion ,using loops
> we not using jsp instead converting buffer to string> and then just displaying it. .is there any other way> then recursion ,using loopsDo you even know what recursion means?
> we not using jsp instead converting buffer to string
> and then just displaying it.
Yes, and any developer who's worth his salt should be aware that it's exactly what not to do.
> .is there any other way
> then recursion ,using loops
Why? It's much more complicated, at least. It'll be difficult to keep the sequence and work with unknown tree depths at the same time.
ok so can i be told about how using html tags in recursion it would be displayed
> ok so can i be told about how using html tags in> recursion it would be displayedNo, probably not.
> whyBecause it would be pissing in the wind. Or in your case, a hurricane force wind.
So in the end what is the final solution i should opt for
> So in the end what is the final solution i should opt> for http://www.geekinterview.com/
> So in the end what is the final solution i should opt forWhat we told you. Switch on your brain and come up with the HTML you need to find out how to produce it, or pass the the task to someone who knows about developing stuff.