Andrew,
Thanks for the response, but, if I could ask just one other thing...
I have tried a couple of things to collapse the node as I re-add it,
but, it doesn't seem to do anything. Can you give some hint as to how I
do this?
This is what I tried (n00b alert)
TreeNodeBase tnb = new
TreeNodeBase(fi[i].getType(),fi[i].getName(),true);
tnb.setIdentifier(fi[i].getPuid());
TreeModelBase tm = new TreeModelBase(tnb);
TreeState ts = tm.getTreeState();
if (ts.isNodeExpanded(fi[i].getPuid()))
ts.toggleExpanded(fi[i].getPuid());
selectedNode.getChildren().add(tnb);
I know this is wrong, but, I am not sure why...
Looking at the issue you posted, you refer to a TreeNode.getNodeId(). I
am using Tomahawk 1.1.1 and I do not have this function...
Also, I have looked at the Wiki, the FAQ, the javadocs and this list but
find myself still needing some explanation on some of the Tomahawk
functions. Are there any other resources you can point me to?
Thanks,
Stan
-----Original Message-----
From: Andrew Robinson [mailto:[EMAIL PROTECTED]
Sent: Saturday, June 17, 2006 7:57 PM
To: MyFaces Discussion
Subject: Re: Deleting Nodes/Branch from Tree
Rows state is by row index not row ID unfortunately (I sumbitted an
issue on this). As a result you will have that issue. Best thing you
can do is write a custom tree state object for your model or manually
expand/collapse the paths when you add/remove nodes.
BTW - You shouln't have to rebuild the branch, but simply remove the
nodes you need to (unless you really need to rebuild the nodes for
some reason).
-Andrew
On 6/17/06, Hughes, Stan <[EMAIL PROTECTED]> wrote:
>
>
>
>
> This may seem counter-productive to some, but, I need to be able to
> dynamically delete and rebuild a tree structure. The thing is, I need
the
> data to always be real-time...
>
>
>
> So, given the tree following:
>
>
>
> A
>
> | A1
>
> | A1.1
>
> B
>
>
>
> How do I, when the user clicks the A node, delete everything beneath
it so
> that I can rebuild it?
>
>
>
> I have tried various things, but, nothing seems to work. The only way
I can
> see to do it is,
>
>
>
> HtmlTree tree = (HtmlTree) component;
>
> selectedNode = (TreeNodeBase) tree.getNode();
>
>
> selectedNode.getChildren().removeAll(selectedNode.getChildren());
>
>
>
> But, this does not work. When the tree is rebuilt, the nodes seem to
keep
> the state of the node that previously occupied that position.
>
> Here is what happens: if the user selects A, then selects A1 (to
expand
> them), and then collapses A by selecting it again, everything looks
normal.
> But if he then selects A to expand it (again), the code is supposed to
> delete everything below A and rebuild the first level below A (like
lazy
> loading). This appears to work also, but, A1, though it has been
deleted and
> newly created, has the state of being expanded - forcing you to select
it
> twice to expand it...
>
>
>
> Is there some way to COMPLETELY remove everything below a node? Or, is
my
> description not clear enough of what is going on?
>
>
>
> Thanks for any help...
>
>
>
>