Tree Events Working in Latest Nightly Builds?

UI Components for JSF
Post Reply
makoto1337
Posts: 82
Joined: 10 Dec 2009, 10:17

07 Jan 2010, 05:36

I have been using the latest nightly build, but for some reason with the new p:tree revision, I cannot get any events from my nodeSelectListener. Here is my tree:

Code: Select all

<p:tree id="tree63" nodeSelectListener="#{treeBeanController.onNodeSelect()}" value="#{treeBean.getModel()}" 
                          dynamic="true" cache="false" update="infoPane" expandAnim="FADE_IN" collapseAnim="FADE_OUT" var="doc">
                     <p:treeNode styleClass="documentStyle">  
                        <h:outputText value="#{doc}" styleClass="nodeContent"/>  
                     </p:treeNode> 
                  </p:tree>
The data is displayed just fine, but I just cannot get events when I click on a p:treeNode. Do I have to do this a different way now?

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

07 Jan 2010, 15:11

Can you try nodeSelectListener="#{treeBeanController.onNodeSelect}" instead of nodeSelectListener="#{treeBeanController.onNodeSelect()}".

Also maybe it's a browser cache issue as scripts are changed. Make sure cache is cleaned. Does the online selection demo work for you?

tcasasent
Posts: 21
Joined: 06 Jan 2010, 21:39

07 Jan 2010, 16:19

Sorry to hijack your thread, but which constructor are you using for your TreeNodes? I'm using TreeNode(Object data, TreeNode parent), but with the tree set to dynamic="true", I always get an unexpected null error in the JavaScript.

-Tod

tcasasent
Posts: 21
Joined: 06 Jan 2010, 21:39

07 Jan 2010, 17:02

Never mind on my question--the Jan 6 build fixes the Jan 5 build.

As far as your tree event question, with the Jan 6 build, clicking on a node and bringing up the dialog box, like from the sample, works fine for me. The only problem I'm having is the it doesn't recognize the selectedNode attribute as belonging to TreeBean.

Code: Select all

		<p:tree id="mytree314"
			value="#{TreeBean.model}"
			var="node"
			dynamic="true"
			cache="false"
			nodeSelectListener="#{TreeBean.onNodeSelect}"
			update="dialogSelectedNode"
			onselectComplete="nodeDialog.show();"
			>
		    <p:treeNode>
			<h:outputText value="#{node.toString()}"/>
		    </p:treeNode>
		</p:tree>
		<p:dialog header="Selected Node" widgetVar="nodeDialog"  draggable="false" width="250px" fixedCenter="true">
		    <h:outputText id="dialogSelectedNode" value="You have selected: #{TreeBean.selectedNode.toString()}" />
		</p:dialog>

makoto1337
Posts: 82
Joined: 10 Dec 2009, 10:17

08 Jan 2010, 03:06

It works now with nodeSelectListener="#{treeBeanController.onNodeSelect}". I was using that before, but another nightly build was broken and wasn't working, so I changed it to nodeSelectListener="#{treeBeanController.onNodeSelect()}" to test it and I forgot to change it back. It works pretty well now, though. Now I just need to figure out how to use the new tree. Is there a draft of the documentation anywhere? I want to know how to set the tree to expand to certain nodes. I also want selected nodes to be highlighted. Can I do that now?

makoto1337
Posts: 82
Joined: 10 Dec 2009, 10:17

08 Jan 2010, 03:22

There is one more bug I found in the tree. When I close an expanded node, open it again, close another node, and open that, then the tree opens and then closes up again. If I try to open it again it just keeps opening and closing automatically, over and over. Here's my tree code:

Code: Select all

<p:tree id="tree63" nodeSelectListener="#{treeBeanController.onNodeSelect}" value="#{treeBean.getModel()}" 
                          dynamic="true" cache="false" update="infoPane" expanded="true" expandAnim="FADE_IN" collapseAnim="FADE_OUT" var="doc">
                     <p:treeNode styleClass="documentStyle">  
                        <h:outputText value="#{doc}" styleClass="nodeContent"/>  
                     </p:treeNode> 
                  </p:tree>
I also tried it with the expanded="true" taken out, and it still does the same thing.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

10 Jan 2010, 13:15

Update user's guide will be released along with the upcoming version which is hopefully very soon. To display a certain node as expanded by default use the setExpanded(true) api on TreeNode.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 13 guests