Help with async tree

UI Components for JSF
ninjapiehole
Posts: 12
Joined: 01 Dec 2009, 19:24

10 Dec 2009, 22:47

I am trying to use the tree component to update another component when something in the tree is selected but can't seem to make it work (BTW I am using Mojarra).

Below is the JSF snippet I am using and my backing bean is pretty a straightforward session bean that generates a 2 level tree, which shows up fine in client toggle mode but then I get no events.

1. No node select events occur but I do see the expand and collapse events.
2. The node doesn't expand in the browser even though the even occurs on the server side.
3. My p:ajax doesn't seem to cause anything to happen (not sure if p:tree and p:ajax work together).

Any advice would be appreciated here. Thanks. I don't see any errors in the log.

Code: Select all

<p:tree value="#{reportTree.model}" toggleMode="async" nodeSelectListener="#{reportTree.onNodeSelect}"
                        cache="false" nodeExpandListener="#{reportTree.onNodeExpand}" nodeCollapseListener="#{reportTree.onNodeCollapse}">

  <p:ajax event="click" actionListener="#{reportTree.nodeAction}" update="instanceGroup"/>

</p:tree>
Thanks!
JSF2 (Mojarra) / Primefaces 2

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

11 Dec 2009, 02:11

I think you are trying to do the same thing I am (c.f., http://primefaces.prime.com.tr/forum/vi ... ?f=3&t=908). The p:ajax doesn't seem to help at all. I am guessing the only way to get this to work is to call a javascript function from onNodeClick, and then us js to refresh an iframe with the component you want to update in it. This is more complicated than it should be, so I hope this can be made easier in the future.

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

11 Dec 2009, 02:55

I implemented my method of refreshing an iframe with content based on the onNodeClick. HOWEVER, the onNodeClick function is called before the nodeSelectListener gets processed, or at least it isn't deterministic. This makes it pretty much impossible to update the content, since my managed bean doesn't get the event from the nodeSelectListener before the iframe displaying content from the managed bean is refreshed. I'm not yet sure how or if I can solve this.

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

11 Dec 2009, 14:44

Do you think p:remoteCommand can help you here until the feature is built-in?

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

It allows you to do ajax calls simply from your javascript. But I think you need a way to pass the selected node to remoteCommand which I can't think of a way right now. Anyway this feature has a high priority. You can watch the progress by voting the following issue, once it's checked in you can grab a nightly build to start using.

http://code.google.com/p/primefaces/iss ... ail?id=371

Thanks all for your feedback! :)

ninjapiehole
Posts: 12
Joined: 01 Dec 2009, 19:24

11 Dec 2009, 18:25

It's too bad this isn't working right now. Is there any idea when this will be available? I am not that strong with Javascript but maybe I can make is work until then, otherwise I will have to roll my own tree component.

Thanks for the replies.
Thanks!
JSF2 (Mojarra) / Primefaces 2

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

11 Dec 2009, 18:49

It should be ready by monday(14th) via a nightly build according to the plan.

ninjapiehole
Posts: 12
Joined: 01 Dec 2009, 19:24

11 Dec 2009, 20:25

Wow. That's quick. You guys are really impressive. Primefaces is great and will probably save me/us a lot of time in the future. I hope to contribute at some point.

Out of curiousity is there any interest in replacing (or supporting) the p:ajax tag with the f:ajax tag? They seem to solve the same problem.

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

13 Dec 2009, 16:00

Thanks for your comments.

We'll keep p:ajax so that we can add extensions to f:ajax in PrimeFaces 2.x.

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

14 Dec 2009, 02:11

I'll also keep an eye on this issue and will try out the nightly build when it becomes available. Good luck!

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

14 Dec 2009, 05:12

I am using the jars from http://97.107.138.40:8080/hudson/job/Pr ... efaces/13/, but I still cannot get the tree to update an outputtext on the page. I tried using both the p:ajax tag and the update tag inside the tree. What is the proper way to get this to work?

No matter what I do it says "component not found to be updated partially." I tried this as a test:

Code: Select all

<body>
<h:form>
<p:tree value="#{treeBean.getModel()}" toggleMode="async" update="proj33" nodeSelectListener="#{treeBeanController.onNodeSelect}"></p:tree>
<h:outputText id="proj33" value="This is a project33. #{treeBeanController.selectedTreeNode}" />
</h:form>  
</body>
This is a very simple example, so it should work. I don't know why it cannot find proj33, unless you are not searching for the id correctly in your code. If I am missing something here, please let me know.
Primefaces 3.3
GlassFish 3.1.2
JSF 2
Java 6

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 25 guests