Ok, the exception in my last message was caused by the fact that I had my 
TreeBacker 
class implement List. So before I go throught implementing this I'd like to at 
least 
feel if this sounds reasonably workable with the tree2 component. 

What I want to do is create a wrapper around my data so I want to implement 
TreeNode, 
List, Iterator in a special wrapper class. Then when TreeBacker.getTreeData is 
called 
I want to return this wrapper as my TreeNode. I was trying to do it with 
TreeBacker 
and having getTreeData return 'this' but since I can't currently implement List 
using 
that class (and it appears to instantiate a new TreeBacker for each branch) I 
guess I 
have to create a separate class.

The reason I want to do this is because I don't want do this:

TreeNode base = new TreeNodeBase("branch", "root", "0", false);
List l = getMyObjects();
Iterator i = l.iterator();
while (i.hasNext()) {
    MyObject o = (MyObject)i.next();
    String type = (o.hasChildren()) ? "branch" : "leaf";
    TreeNode node = new TreeNodeBase(type, o.getDescription(), new 
String(o.getId()), 
(type.equals("leaf")));
    recurseOn(o.getChildren());
    base.getChildren().add(node);
}

for all of my objects. I'd like just create an adapter using the TreeNode 
interface 
and go:

new MyTreeNodeImpl(getMyFirstLevelObjectList()) and then return that for the 
TreeNode 
and internally retrieve the children when someone clicks on a branch and return 
the 
interface requests by looking at my object. 

Does this sound like something tree2 is capable of handling? Or am I expected 
to use 
TreeNodeBase? It would also be really neat if I can access MyObject from the 
TreeNode 
interface so I can display additional data from it if I want to: 
TreeNode.getObject() 
but I can live with the server-side pull if that'll work.


--
Rob

@objectsource.org

Reply via email to