You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Jeffrey Goodwin <JG...@uamail.albany.edu> on 2005/04/29 02:58:18 UTC

How to dynamically add nodes to the Tree Component

Hi,

I am working on a project in which I need to dynamically create a large tree
with a large number of child nodes/levels.  Since the tree will be large, I
plan to create all parent nodes and then only add the children when a node
is exanded or selected.  Is this possible with the MyFaces tree component?
If so, are there any working examples in which child nodes are dynaically
added to the tree when a node is exanded/selected?  To clarify I am trying
to avoid building the entire tree and populating every node.

Thanks in advance,
Jeff 

Re: How to dynamically add nodes to the Tree Component

Posted by Sean Schofield <se...@gmail.com>.
This is definitely possible with both tree components.  There are two
tree components: tree and tree2.  I worked on tree2 which supports
client-side toggle in addition to server-side toggle.  You're talking
about server-side toggle (you'll want to process the expand action on
the server using actionListener instead of on the client-side using
javascript.)

First order of business: you should check out the latest examples in
the simple examples webapp.  You can get the source in CVS or get the
binaries from nightly builds.  The latest source/nighlties have new
tree2 examples that are not in 1.0.9m9.  There are no examples showing
the dynamic addition of data but it would be relatively easy to come
up with one.  Perhaps I will add one at some point.  There's enough
there that you should be able to figure it out though.  Feel free to
contribute an example yourself if you come up with one.

sean


On 4/28/05, Jeffrey Goodwin <JG...@uamail.albany.edu> wrote:
> Hi,
> 
> I am working on a project in which I need to dynamically create a large tree
> with a large number of child nodes/levels.  Since the tree will be large, I
> plan to create all parent nodes and then only add the children when a node
> is exanded or selected.  Is this possible with the MyFaces tree component?
> If so, are there any working examples in which child nodes are dynaically
> added to the tree when a node is exanded/selected?  To clarify I am trying
> to avoid building the entire tree and populating every node.
> 
> Thanks in advance,
> Jeff
>