Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Patrick Tsang
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64608
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Patrick Tsang
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 502
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Sean Stephens
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic