Keep tree state

UI Components for JSF
Post Reply
soekris
Posts: 76
Joined: 29 Apr 2013, 16:54
Location: Barcelona

19 Oct 2014, 22:43

Hello

I wonder if it's somehow to keep sate between posts in a tree. I would like to keep if a node it's expanded or not, and if a node is selected or not.

here you can see an example, you can submit the form but tree keeps its state (thru cookies). How can I achive it?

http://primefaces-rocks.appspot.com/ui/tree.jsf

Thanks
Primefaces 5.3.X / 6.X
NetBeans 8.1
WildFly 10
Linux Mint & freeBSD

soekris
Posts: 76
Joined: 29 Apr 2013, 16:54
Location: Barcelona

20 Oct 2014, 16:51

Hello

I get it. "Simply" you have to declare this two events:

<p:ajax event="expand" update=":formTree:messages" listener="#{facturesBean.onNodeExpand}" />
<p:ajax event="collapse" update=":formTree:messages" listener="#{facturesBean.onNodeCollapse}" />

Surprising that nobody in the list knew it neither in the official doc.

Cheers
Primefaces 5.3.X / 6.X
NetBeans 8.1
WildFly 10
Linux Mint & freeBSD

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

20 Oct 2014, 17:10

Hi,

Glad you found the solution yourself and for posting it... Several remarks though why you might not have gotten a (quick) response:
- The 'showcase' you refer to is ancient (almost prehistoric, it says: "Running PrimeFaces-3.0-SNAPSHOT on Mojarra-2.0.4"). The latest version is 5.1, so for '3.0-SNAPSHOT' questions, I do not even try to reply
- You did not post which version you were actually using, so this is another reason not to reply
- It was weekend when you posted your question and it is now just one (1!!!) day later. We all give support in our free time, which is often in the evenings, so a little patience is required
- The oficial docs DO contain info about this... page 480 to be exact, I just checked.

Cheers

soekris
Posts: 76
Joined: 29 Apr 2013, 16:54
Location: Barcelona

20 Oct 2014, 18:06

Hi kukeltje

The showcase I refer it was only put as an example

In my signature there is my PF and mojarra version

It was weekend, it's true, but it's not the first time I had the same experience or I have seen other questions and nobody answer it. I know, it's free suport, but times are changing my friend.

I check 480 page in PF user guide 5.1 doc, it doesn't speak about tree it speaks about toolbar. I recheck tree part 484-493 and it doesn't put that you must declare this two events to keep the state.

There is something it's not working in this list

Cheers
Primefaces 5.3.X / 6.X
NetBeans 8.1
WildFly 10
Linux Mint & freeBSD

User avatar
andyba
Expert Member
Posts: 2473
Joined: 31 Mar 2011, 16:27
Location: Steinfeld, near Bremen/Osnabrück, DE
Contact:

21 Oct 2014, 08:21

If the model you use is at least @ViewScoped then state will be maintained through AJAX requests or any other request that don't cause the user to leave the current view.
even if you use a dynamic tree this is the case. The event listeners are their to allow you to implement lazy loaded trees or manipulate the state of other beans/components.
PF 4.x (Elite versions), PF 5, Pf 5.1, PF 6.0
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 35 guests