Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print a "tree" structure in JSP page

I'm trying to print out a "tree" structure in my JSP page that looks something like this:

Root
 |
 |----Dependencies
 |        |----A
 |        |----B
 |        |----C
 |
 |----Dependents
          |----D
          |----E

I'm hoping that someone around here knows of some utility that would help me do my job (it can use any technology, just as long as I can insert it in my JSP page). The Root and the other variables are all Strings (A, B, C etc...).

I'm planning on using something like this: (I haven't written this yet, so I'm not sure if it'll work...)

public class DependencyTree 
{ 
  private String root; 
  private ArrayList<String> dependencies, dependents; 
} 

Basically, root corresponds to "root" on my example above, and the two ArrayLists contain A, B, C and D, E respectively.

like image 308
Raymond Avatar asked Dec 11 '25 00:12

Raymond


1 Answers

If you don't mind using some javascript to render the tree in your JSP, jsTree is a jQuery component which supports JSON and XML data sources to populate a tree view:

http://ajaxian.com/archives/jstree-jquery-based-javascript-tree-component

Edit: Here is some more specific information on getting started with the component: http://www.jstree.com/documentation/core

like image 132
Mike G Avatar answered Dec 13 '25 14:12

Mike G



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!