Thanks a lot Andrew.  One last question, the only alternative to getting the
nodeId is using binding or you know any other.  I am currently using too
much binding in my application and I am concerned whether this can cause
serious memory issues in some cases, for instance my tree is in session
scope so probably it wouldn’t be too ideal to include a binding in it, or
what do you think in relation to this subject?

Regards,

JV

 

  _____  

De: Andrew Robinson [mailto:[EMAIL PROTECTED] 
Enviado el: viernes, 12 de enero de 2007 18:06
Para: MyFaces Discussion
Asunto: Re: Tree2 parent node expand actions...

 

Node ID isn't on the treeModelBase it is on UITreeData

On 1/12/07, Jorge Vásquez <[EMAIL PROTECTED]> wrote: 

Thanks Andrew but it isn't working.

I am getting the exception:

 

javax.faces.el.PropertyNotFoundException: Bean:
org.apache.myfaces.custom.tree2.TreeModelBase, property: nodeId
        at
org.apache.myfaces.el.PropertyResolverImpl.getPropertyDescriptor(PropertyRes
olverImpl.java:483)
        at
org.apache.myfaces.el.PropertyResolverImpl.getPropertyDescriptor(PropertyRes
olverImpl.java:454)
        at
org.apache.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolverImpl.
java:417)
 
        at
org.apache.myfaces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.jav
a:82)
 
        at
org.apache.myfaces.el.ELParserHelper$MyPropertySuffix.evaluate(ELParserHelpe
r.java:532)
 
        at
org.apache.commons.el.ComplexValue.evaluate(ComplexValue.java:145)
        at org.apache.myfaces.el.ValueBindingImpl.getValue
(ValueBindingImpl.java:383)
        at
org.apache.myfaces.custom.updateactionlistener.UpdateActionListener.getValue
(UpdateActionListener.java:95)
        at
org.apache.myfaces.custom.updateactionlistener.UpdateActionListener.processA
ction
(UpdateActionListener.java:129)
        at
javax.faces.event.ActionEvent.processListener(ActionEvent.java:48)
        at
javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:484)
        at javax.faces.component.UICommand.broadcast(UICommand.java:75)
 
        at
org.apache.myfaces.custom.tree2.UITreeData.broadcast(UITreeData.java:143)
 
        at
javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:94)

 

Any idea on how can I obtain the nodeId?

 

Regards and thanks a lot,

JV

 

  _____  

De: Andrew Robinson [mailto:[EMAIL PROTECTED] 
Enviado el: jueves, 11 de enero de 2007 15:08
Para: MyFaces Discussion
Asunto: Re: Tree2 parent node expand actions...

 

Change the node contents to a commandLink with an updateActionListener and
in the "actionListener" method, toggle the expanded state of the node in the
tree state. Something like:

<t:tree2 var="node" binding="#{ bean.tree}" ... >
<f:facet name="node">
<t:commandLink actionListener="#{bean.toggleNodeExpansion}">
<t:updateActionListener property="#{bean.activeNodePath}" value="#{
bean.tree.nodeId}" />
</t:commandLink>
</f:facet>
</t:tree2>

public class Bean {
  private UITreeData tree;
  private String activeNodePath;
  private TreeModel treeModel; 
  public UITreeData getTree() { return this.tree; }
  public void setTree(UITreeData tree) { this.tree = tree; }
  public TreeModel getTreeModel() { return this.treeModel; }
  public String getActiveNodePath() { return this.activeNodePath; }
  public void setActiveNodePath(String activeNodePath) { this.activeNodePath
= activeNodePath; }
  public void toggleNodeExpansion(ActionEvent evt) {
    if (activeNodePath == null) return; 
 
treeModel.getTreeState().toggleExpanded(treeModel.getPathInformation(activeN
odePath));
  }
}

If you can get the node path (ie "0:1:2") without using the getNodeId
property then you can avoid using binding. 

-Andrew

On 1/11/07, Jorge Vásquez <[EMAIL PROTECTED]> wrote:

Regards to all,

First of all happy new year!!!

 

I have been trying to add the option to parent nodes so that  the user can
open each tree branch either by clicking on the "plus" or by clicking on the
name of the node (see image below).

 



 

In this image the node should open both by clicking the "plus" and by
clicking the folder name.  So far in order to open a node the only way is
clicking on the "plus".

 

Is this possible?  Does anybody have some sample code where this works?

 

Thanks in advance,

JV

 

 

<<attachment: image001.jpg>>

Reply via email to