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]
# 1

> 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?

cotton.ma at 2007-7-12 11:44:14 > top of Java-index,Java Essentials,Java Programming...
# 2
yes it is webpage .
Akritia at 2007-7-12 11:44:14 > top of Java-index,Java Essentials,Java Programming...
# 3
> yes it is webpage .Well then a HTML and/or JavaScript forum is what you need.
cotton.ma at 2007-7-12 11:44:14 > top of Java-index,Java Essentials,Java Programming...
# 4
can you please give me the link of forum where i can post my query as i am new to this forum
Akritia at 2007-7-12 11:44:14 > top of Java-index,Java Essentials,Java Programming...
# 5
> 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.
cotton.ma at 2007-7-12 11:44:14 > top of Java-index,Java Essentials,Java Programming...
# 6

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

Akritia at 2007-7-12 11:44:14 > top of Java-index,Java Essentials,Java Programming...
# 7
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?
cotton.ma at 2007-7-12 11:44:14 > top of Java-index,Java Essentials,Java Programming...
# 8
dont know how to display them
Akritia at 2007-7-12 11:44:14 > top of Java-index,Java Essentials,Java Programming...
# 9

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.

CeciNEstPasUnProgrammeura at 2007-7-12 11:44:14 > top of Java-index,Java Essentials,Java Programming...
# 10
> And the keyword the OP is looking for is> "recursion".> But what if he wants to do it dynamically?
cotton.ma at 2007-7-12 11:44:14 > top of Java-index,Java Essentials,Java Programming...
# 11

> 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=

cotton.ma at 2007-7-12 11:44:14 > top of Java-index,Java Essentials,Java Programming...
# 12
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.
Akritia at 2007-7-12 11:44:14 > top of Java-index,Java Essentials,Java Programming...
# 13

> 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.

CeciNEstPasUnProgrammeura at 2007-7-12 11:44:14 > top of Java-index,Java Essentials,Java Programming...
# 14
> 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.
cotton.ma at 2007-7-12 11:44:14 > top of Java-index,Java Essentials,Java Programming...
# 15
we not using jsp instead converting buffer to string and then just displaying it. .is there any other way then recursion ,using loops
Akritia at 2007-7-21 21:26:22 > top of Java-index,Java Essentials,Java Programming...
# 16
> 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?
cotton.ma at 2007-7-21 21:26:22 > top of Java-index,Java Essentials,Java Programming...
# 17
yes
Akritia at 2007-7-21 21:26:22 > top of Java-index,Java Essentials,Java Programming...
# 18

> 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.

CeciNEstPasUnProgrammeura at 2007-7-21 21:26:22 > top of Java-index,Java Essentials,Java Programming...
# 19
ok so can i be told about how using html tags in recursion it would be displayed
Akritia at 2007-7-21 21:26:22 > top of Java-index,Java Essentials,Java Programming...
# 20
> ok so can i be told about how using html tags in> recursion it would be displayedNo, probably not.
cotton.ma at 2007-7-21 21:26:22 > top of Java-index,Java Essentials,Java Programming...
# 21
why
Akritia at 2007-7-21 21:26:22 > top of Java-index,Java Essentials,Java Programming...
# 22
> whyBecause it would be pissing in the wind. Or in your case, a hurricane force wind.
cotton.ma at 2007-7-21 21:26:22 > top of Java-index,Java Essentials,Java Programming...
# 23
So in the end what is the final solution i should opt for
Akritia at 2007-7-21 21:26:22 > top of Java-index,Java Essentials,Java Programming...
# 24
> So in the end what is the final solution i should opt> for http://www.geekinterview.com/
cotton.ma at 2007-7-21 21:26:22 > top of Java-index,Java Essentials,Java Programming...
# 25
> 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.
CeciNEstPasUnProgrammeura at 2007-7-21 21:26:22 > top of Java-index,Java Essentials,Java Programming...