Hi Chris,

If I get what you mean by this approach, does this mean my backing bean for
the tree itself will be MyBaseNode1 object because it is from that object
where i will point my actionListener, myBaseNode1.onClick, is that right?


Christopher Cudennec wrote:
> 
> Hi!
> 
> as long as the code of method "setNodeSelected" does not depend on 
> having an instance of ActionEvent you could simple pass "null" as a 
> parameter. In my opinion you should do some refactoring because you use 
> "action" and "actionListener" at the same time. The "action" method is 
> basically used for navigation and that is not what you want to do here. 
> You probably just return "null", right? Why not doing throwing away the 
> action and doing something like:
> 
> interface ClickableBaseNode {
>   public void onClick(ActionEvent event);
> }
> 
> class MyBaseNode1 extends TreeNodeBase implements ClickableBaseNode {
>   public void onClick(ActionEvent event) {
>     setNodeSelected(event);
>     ClickableBaseNode anotherNode = findAnotherNode();
>     anotherNode.onClick();
>   }
> }
> 
> class MyBaseNode2 extends TreeNodeBase implements ClickableBaseNode {
>   public void onClick(ActionEvent event) {
>     setNodeSelected(event);
>     getTreeBacker().processFolder();
>   }
> }
> 
> You just have to create proper implementations of "ClickableBaseNode" 
> that suit your needs.
> 
> Christopher
> 
> kewldude schrieb:
>> Thanks Christopher, I got the idea, but this is where I am really
>> struggling.
>> Together with executing the action associated with the node, I have to
>> change its styleclass to reflect that it was as if the node was clicked.
>> To
>> achieve that using the normal way, my command link has this:
>>
>> <a4j:commandLink id="a4jLink" styleClass="#{t.nodeSelected?
>> 'documentSelected':'document'}" action="#{treeBacker.processFolder}"
>> actionListener="#{t.setNodeSelected}" reRender="a4jGroup"  >                 
>>
>> To do that programmatically, I think I have to invoke the setNodeSelected
>> in
>> the backing bean, the problem now is the setNodeSelected is associated
>> with
>> an ActionEvent, I dont have an ActionEvent object because there was no
>> actual action that generates the event , I'm just simulating the "event"
>> programmatically. Any more hints?...                                         
>>                                                          
>>
>>
>> Christopher Cudennec wrote:
>>   
>>> Hi there,
>>>
>>> you could implement your own TreeNode adding a new method "onClick" (or 
>>> whatsoever) that can be called when you found the match in your backing 
>>> bean. Does that solve your problem? (Look here for a start: 
>>> http://myfaces.apache.org/tomahawk/apidocs/org/apache/myfaces/custom/tree2/TreeNodeBase.html)
>>>
>>> Cheers,
>>>
>>> Christopher
>>>
>>> kewldude schrieb:
>>>     
>>>> Here goes the situation, I have a textbox that can search through the
>>>> nodes
>>>> in the tree2 component. When there is a match, I need to expand the
>>>> specific
>>>> node. I can do that part no problem. But together with expanding that
>>>> node,
>>>> the action associated to that node should also be executed (it was as
>>>> if
>>>> that node was clicked), how can I do that? or is it possible to do that
>>>> all?
>>>> any hints...thanks.
>>>>   
>>>>       
>>>
>>>     
>>
>>   
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Tree2---Selecting-a-node-programmatically-tf4279246.html#a12219518
Sent from the MyFaces - Users mailing list archive at Nabble.com.

Reply via email to