Hi Doug,
First I would make sure your TreeNode implementation creates children
lazily. You probably should only create children when children() is
actually called and provide logic for isLeaf and getChildCount() that
don't require creating the children.

You can create the initial state for the tree by overrriding
newTreeState(). I usually do something like this:

 protected ITreeState newTreeState()
    {

        ITreeState state = new DefaultTreeState();
        state.collapseAll();
        TreeModel treeModel = (TreeModel) getModelObject();
        OutLineNode root = (OutLineNode) treeModel.getRoot();
        if(null != childNodeExpansionStrategy) {
            childNodeExpansionStrategy.expandNode(root, state);
        } else {
            if (log.isInfoEnabled()) {
                log.info("childNodeExpansionStrategy is NULL.
expanding root only");
            }
            state.expandNode(root);
        }
        return state;
    }

where childNodeExpansionStrategy holds the logic to determine the
level to expand to, and recurses through the nodes to get there,
calling state.expandNode(node) until it does.

best,
jim

On 8/3/07, Doug Leeper <[EMAIL PROTECTED]> wrote:
>
> I would like to dynamically add tree nodes to an AbstractTree instead of
> loading the entire tree up front.  Not sure how do this.  I thought I would
> be able to override nodeExpanded(TreeNode) and check if the node had been
> "loaded" ...if not then load 1 level deep.  However, all ITreeStateListeners
> are final in AbstractTree.
>
> Is there a way to do this without creating my own version of AbstractTree?
> Better yet...is there an example of this...it could mimic the file structure
> of your computer.
>
> Thanks
> - Doug
> --
> View this message in context: 
> http://www.nabble.com/Dynamically-adding-tree-nodes-upon-selection-tf4212940.html#a11984616
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to