p:tree Updating of Components with a nodeSelectListener

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

14 Dec 2009, 10:27

I have the following code:

Code: Select all

<p:tree id="tree63" nodeSelectListener="#{treeBeanController.onNodeSelect}" value="#{treeBean.getModel()}" 
                                   toggleMode="async" expanded="true" update="infoPane" />
and all I want to do is update the values in my infoPane to display new values when a new node is selected. However, it seems the update is called either non-deterministically or always before the nodeSelectListener gets called. This makes it impossible to set the value I need in my managed bean and then display new data in a pane with the update. Is there a way to make it so the event listeners for the async tree can be called before the update for the ppr? Is there a better way to do what I am trying to do? For example, can I get the currently selected node from the UIComponent for the tree (i.e., the Tree class). It seems that your Tree.java does not store the currently selected node, even for the async version.

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

14 Dec 2009, 11:43

Update is called at render phase meaning after everything is completed. Following example would help, it's not deployed online yet so I'm sending the link for source;

http://code.google.com/p/primefaces/sou ... ents.xhtml

You need latest snapshot build for this.

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

15 Dec 2009, 02:24

I think I figured out my problem, but I see no solution to it. The problem was I was updating a component with c:choose statements in it. Those must be getting processed before the nodeSelectListener finishes, so the problem is that and not the update. At any rate, I will find a workaround. With the c:choose statements, everything works as expected.

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

15 Dec 2009, 12:23

There is one bug in your async tree from the nightly build. If I have expanded="true" for the async mode, I always get the following stack trace when the node depth is greater than 2.

[#|2009-12-15T19:23:51.634+0900|WARNING|glassfishv3.0|javax.enterprise.resource.webcontainer.jsf.lifecycle|_ThreadID=37;_ThreadName=Thread-1;|For input string: ""
java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:470)
at java.lang.Integer.parseInt(Integer.java:499)
at org.primefaces.model.TreeExplorerImpl.findTreeNode(TreeExplorerImpl.java:26)
at org.primefaces.component.tree.TreeRenderer.decode(TreeRenderer.java:58)
at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:790)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1047)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1042)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1042)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1042)
at javax.faces.component.UIForm.processDecodes(UIForm.java:216)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1042)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1042)
at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:941)
at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:332)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:233)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:789)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:697)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:952)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:166)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
at java.lang.Thread.run(Thread.java:637)
|#]

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

16 Dec 2009, 02:02

Hi, we'll look into this isssue.

About c:choose mixing jstl with jsf is always problematic and it's not the best practice.

By the way online demo for nodeSelectListener with ajax update is live now;

http://www.primefaces.org:8080/prime-sh ... Events.jsf

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 48 guests