You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Yixing Ma <yi...@interfacemgmt.net> on 2006/01/27 18:42:39 UTC

tree2 setNodeSelected()

Hi, the great myfaces users and devs,

I really need some help regarding the tree2.

I know I can use t.setNodeSelected() to select the tree node. And rendering the tree node based on the selection.

But how to deselect the tree node?

How to refresh the tree to make all the nodes unselected?

I cannot do something like below, coz the deselection event is not triggered by clicking on the tree. Anyone can help me?

        public void processAction(ActionEvent event) throws 
                AbortProcessingException { 
                UIComponent component = (UIComponent) event.getSource(); 
                while (!(component != null && component instanceof 
                HtmlTree)) { 
                        component = component.getParent(); 
                } 
                if (component != null) { 
                        HtmlTree tree = (HtmlTree) component; 
                        TestNode node = (TestNode) tree.getNode(); 
                        ... 
                } 
                ... 
        } 


Re: tree2 setNodeSelected()

Posted by Yixing Ma <yi...@interfacemgmt.net>.
Hi Sean,

I appreciate your time to reply my email.

Here is my situation,

I click on one node of the tree, make it highlighted (or say selected), then 
on another frame, I do some process based on that node's identity, and then 
go back to the tree.

At that moment, I want to see the original tree that no node is selected.

Is that possible?

To make it clear, I attached a screenshot of my page.

----- Original Message ----- 
From: "Sean Schofield" <se...@gmail.com>
To: "MyFaces Discussion" <us...@myfaces.apache.org>
Sent: Friday, January 27, 2006 10:30 AM
Subject: Re: tree2 setNodeSelected()


Its been a while since I worked on tree2 but I'm planning to get back
to it soon now that the maven stuff is mostly finished.

You said all of the nodes unselected but only one node can be selected
at a time.  Did you mean collapsed instead?  If you really did mean
unselected, unfortunately the selected status is only easily
accessible through the action event (which knows to apply itself to
the correct node.)

A while back we introduced TreeState and TreeModel interfaces.
Unfortunately that only helps you with expand/collapse.  I need to get
back to MYFACES-911 which will add a lot of new flexability to tree2.
Unfortunately the patch is now broken because of the maven reorg so I
need to rework it.

Sean

On 1/27/06, Yixing Ma <yi...@interfacemgmt.net> wrote:
>
>
> Hi, the great myfaces users and devs,
>
> I really need some help regarding the tree2.
>
> I know I can use t.setNodeSelected() to select the tree node. And 
> rendering
> the tree node based on the selection.
>
> But how to deselect the tree node?
>
> How to refresh the tree to make all the nodes unselected?
>
> I cannot do something like below, coz the deselection event is not 
> triggered
> by clicking on the tree. Anyone can help me?
>
>         public void processAction(ActionEvent event) throws
>                 AbortProcessingException {
>                 UIComponent component = (UIComponent) event.getSource();
>                 while (!(component != null && component instanceof
>                 HtmlTree)) {
>                         component = component.getParent();
>                 }
>                 if (component != null) {
>                         HtmlTree tree = (HtmlTree) component;
>                         TestNode node = (TestNode) tree.getNode();
>                         ...
>                 }
>                 ...
>         }
>
>

Re: tree2 setNodeSelected()

Posted by Sean Schofield <se...@gmail.com>.
Its been a while since I worked on tree2 but I'm planning to get back
to it soon now that the maven stuff is mostly finished.

You said all of the nodes unselected but only one node can be selected
at a time.  Did you mean collapsed instead?  If you really did mean
unselected, unfortunately the selected status is only easily
accessible through the action event (which knows to apply itself to
the correct node.)

A while back we introduced TreeState and TreeModel interfaces.
Unfortunately that only helps you with expand/collapse.  I need to get
back to MYFACES-911 which will add a lot of new flexability to tree2. 
Unfortunately the patch is now broken because of the maven reorg so I
need to rework it.

Sean

On 1/27/06, Yixing Ma <yi...@interfacemgmt.net> wrote:
>
>
> Hi, the great myfaces users and devs,
>
> I really need some help regarding the tree2.
>
> I know I can use t.setNodeSelected() to select the tree node. And rendering
> the tree node based on the selection.
>
> But how to deselect the tree node?
>
> How to refresh the tree to make all the nodes unselected?
>
> I cannot do something like below, coz the deselection event is not triggered
> by clicking on the tree. Anyone can help me?
>
>         public void processAction(ActionEvent event) throws
>                 AbortProcessingException {
>                 UIComponent component = (UIComponent) event.getSource();
>                 while (!(component != null && component instanceof
>                 HtmlTree)) {
>                         component = component.getParent();
>                 }
>                 if (component != null) {
>                         HtmlTree tree = (HtmlTree) component;
>                         TestNode node = (TestNode) tree.getNode();
>                         ...
>                 }
>                 ...
>         }
>
>