title: convert parent/child data to HTML tree structure using jquery
body: <p>I have a Java List containing objects with hierarchical data (id, name, parentId) and need to generate an HTML tree structure (using something like <a href="http://wwwendt.de/tech/dynatree/doc/samples.html" rel="nofollow">DynaTree</a>) with expand/collapse features.  All the examples I've seen require generating nested <code>&lt;ul&gt;</code> structures to represent parent/child/.../n-child/ hierarchies, etc.  </p>
  
  <p>I could convert the data to build this structure.  But, I'd think this data format would work in its current form (id/name/parentId).  Is there a jquery API that can handle this data?</p>
  
  <p>here is an abbreviated example..</p>
  
  <pre><code>//Category has an id, name, parentId
  List&lt;Category&gt; categoryTree = new ArrayList&lt;Category&gt;();
  categoryTree.add(new Category(1, 'root', null));
  categoryTree.add(new Category(2, 'colors', 1));
  categoryTree.add(new Category(3, 'blue', 2));
  categoryTree.add(new Category(4, 'red', 2));
  categoryTree.add(new Category(5, 'shapes', 1));
  categoryTree.add(new Category(6, 'round', 5));
  
  //now, I need to convert this to dynamic javascript to build the tree structure (&lt;ul&gt;, etc)
  </code></pre>
  
  <p>I've used SmartGWT like this before and its trivial to convert this into a tree node structure (see <a href="http://www.java2s.com/Code/Java/GWT/ParentLinkingTreeSampleSmartGWT.htm" rel="nofollow">this example</a>).  I'd think there was a jQuery API to do the same...perhaps not</p>