p:panel / p:accordionPanel dont keep state

UI Components for JSF
rene.guenther
Posts: 56
Joined: 19 Oct 2009, 15:56

22 Oct 2009, 19:47

Hello ,

we just started with primefaces. We'd like to keep the collapsed/expanded state between requests of p:panel or p:accordionPanel.
Since I also don't know the YUI framework, I have no idea how to do those things. Is it in principle possible to keep that state?

Thanks
Rene

User avatar
skillassert
Posts: 12
Joined: 06 Sep 2009, 21:18

22 Oct 2009, 20:45

Yes. It is possible to maintain the state of the selected tab of the accordionPanel through the activeIndex attribute. To enable multiple selection, use comma as separator.

Code: Select all

  <p:accordionPanel multipleSelection="true" fade="true" activeIndex="#{yourbackingbean.activeIndex}">
where you can assign a String value of 1,2 to #{yourbackingbean.activeIndex}

rene.guenther
Posts: 56
Joined: 19 Oct 2009, 15:56

22 Oct 2009, 20:56

Thank you. I saw that attribute but I thought it would only work with single selection :oops:

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

22 Oct 2009, 23:32

Rene, accordionPanel keeps it's state between requests, there's a hidden variable keeping track of active tab indexes. activeIndex attribute is used more likely to define which tabs are expanded by default.

But panel, I guess you meant panel with toggle="true", it doesn't keeps it state but we can add it as an enhancement for the upcoming release. I've created a new issue for this;

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

rene.guenther
Posts: 56
Joined: 19 Oct 2009, 15:56

22 Oct 2009, 23:56

Yes, I meant the panel with toogle=true.
I tried accordionPanel now and it keeps the state and it is actually useful in that regard but it looks like that I cant nest a tabView in an accordionPanel. With the panel I didnt had that issue.

cheers
rene

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

22 Oct 2009, 23:59

Can you post your tabview in accordion panel code Rene so that I can try to run it locally.

rene.guenther
Posts: 56
Joined: 19 Oct 2009, 15:56

23 Oct 2009, 00:24

I cant reproduce it anymore. Probably I had some tags at the wrong place while rearranging the form. Now its working pretty good with the accordionpanel :)

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

23 Oct 2009, 01:17

Done ;) I've changed panel to be stateful as well along with some refactoring and other improvements. Now panel keeps it's toggle state along subsequent requests. In addition a new optional feature called collapsed is added to control the initial state of panel. So if you set collapsed="#{boolean el}, rendering of body will be conditional.

You can grab these via a 1.0.0.RC SNAPSHOT;

http://repository.prime.com.tr/org/prim ... -SNAPSHOT/

rene.guenther
Posts: 56
Joined: 19 Oct 2009, 15:56

23 Oct 2009, 11:36

Thanks! We going to try the RC soon. The accordion works pretty well for requirements too though.

Rene

Robelind
Posts: 15
Joined: 01 Dec 2009, 09:11

22 Oct 2010, 10:55

I'm having a problem with the p:panel toggle state, using PrimeFaces 1.1.
I have a panel like:

Code: Select all

<h:form id="panelForm">
	<p:panel header="Panel" toggleable="true">
		<h:outputText value="Panel content" />
	</p:panel>
	<h:commandButton value="Submit" />
</h:form>
If I collapse the panel and submit, it is not collapsed when the page renders again.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 56 guests