aspose file tools*
The moose likes JSP and the fly likes Any good solution to build a dynamic navigation tree in Java? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Any good solution to build a dynamic navigation tree in Java?" Watch "Any good solution to build a dynamic navigation tree in Java?" New topic
Author

Any good solution to build a dynamic navigation tree in Java?

Patrick Tsang
Greenhorn

Joined: Aug 31, 2004
Posts: 12
All datas that will displayed in the tree are stored in database, and it's required to refresh the navigation tree, and all branchs can be colapsed/expanded.

I searched some solution, but most of them are in javascript and binding
with the static/fixed data in the tree.

Any hints?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61188
    
  66

Well, unless you want to make a round-trip to the server every time a node is opened or closed (which is pretty ridiculous unless the server response is close to instantaneous), you need to use a client-side solution like Javascript or an applet.

Server-side technology can help you dynamically create the tree data from where ever it comes from, but for the client end, you need a client-side technology.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Patrick Tsang
Greenhorn

Joined: Aug 31, 2004
Posts: 12
In my project, the current implementation is to generate the navigation tree on server-side with the JAVA/XML/XSLT. Is that a better solotion?I heard of JAXB, but not sure whether it owns a competative edge on this.

On the client-side expand/collapse, it seems javascript is the only reasonalbe solution? Correct me if I am wrong.
Sean Stephens
Ranch Hand

Joined: Oct 25, 2004
Posts: 40
Besides javascript on the client side, I think applets are the only other somewhat reasonable solution.

Getting the data to the page can be done any number of ways and depends more on your application architecture than this particular feature.

- Sean
Jayesh Lalwani
Ranch Hand

Joined: Nov 05, 2004
Posts: 502
Originally posted by Sean Stephens:
Besides javascript on the client side, I think applets are the only other somewhat reasonable solution.

Getting the data to the page can be done any number of ways and depends more on your application architecture than this particular feature.

- Sean


*dons flame retardent suit*
Applets.. YUCK!!!

I'd rather use java script. If that doesnt work I'd rather use an ActiveX control
Ajith Anand
Ranch Hand

Joined: Aug 30, 2004
Posts: 40
I use a server-side XML / XSLT based solution to build such explorer / tree interfaces. I have the metadata for building the explorer / tree interface in an XML file. Using XSLT I transform the Interface to react to the user interaction.

Client-side java scripts werent a good idea for me, because I have seen how messy it can get when it comes to cross browser issues and the hacks you have to incorporate. Even after all this you can hardly be sure that it works the way you want it.

Unlike client-side "validations", where round-trips can at times prove costly or unwarranted; With these interfaces , along with the change in the "VIEW" of the interface, the client would most of the times require to fetch new content from the server as a response to the change in the tree / explorer view, so it is anyways making a roundtrip.....
[ November 11, 2004: Message edited by: Ajith Anand ]

LXI Technologies P Ltd
[url]www.lxisoft.com[/url]
Sean Stephens
Ranch Hand

Joined: Oct 25, 2004
Posts: 40
I'm not a fan of Applets either... but was trying to be informational for a change instead of my normally opinionated self :-) I'm new here - gotta keep a good rep ;-)

So with that XML/XSLT solution, you are going to the server even when nodes are only opened to see their child nodes. If the tree is "small" and the server hits are tolerable, or if you have to perform business logic to build out the next level in the tree, then its tolerable.

In most cases I've seen, the logic to determine child nodes is not positional in the tree, but is page or higher scope information dependent (is that a real sentence?). Generally there is no more information required to build out a tree all at once, or one level at a time. In some cases its easier to do it all at once.

Blah, I ramble. The only time a request is necessary in my experience (not saying I can't dream up a case where its not so) is when you click on a leaf node or somehow want to act on the Node other than open and see whats in it.

As we all know there are a dozen ways to skin a cat, the way you decide to do it just depends on what results and side effects you feel you need to maximize.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Any good solution to build a dynamic navigation tree in Java?