Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can't get all p:accordionPanel tabs closed by default

I can't get all p:accordionPanel tabs closed

I tried both solutions recommended in Question Hiding the first tab of accordion panel in JSF Primefaces but it does not work for me in case the value attribute of the accordionPanel is an EL expression. the first tab is always open.

I tried

<p:accordionPanel widgetVar="accordion" 
multiple="true" 
value="#{cc.attrs.managedBean.getTabs()}" var="r">

without success

and

<p:accordionPanel activeIndex="-1" 
multiple="true" value="#{cc.attrs.managedBean.getTabs()}" var="r">

works only if there is no value attribut of accordionPanel

thanks for any help.

I have primesfaces 3.3.1

like image 329
Aziz Mehdaoui Avatar asked Jan 09 '13 20:01

Aziz Mehdaoui


2 Answers

Using 'null' worked for me: <p:accordionPanel activeIndex="null">

I'm using PF 3.5 and setting activeIndex to null leaves the tabs closed by default.

like image 134
mjones4 Avatar answered Nov 11 '22 22:11

mjones4


I am using PF 3.5 and with this version I have realized that if I give a negative number for activeIndex greater than the number of tabs in the p:accordianPanel, it collapses all the tabs. E.g.

<p:accordionPanel activeIndex="-2">
   <p:tab title="Hello">
   </p:tab>
   <p:tab title="World">
   </p>
 </p:accordionPanel>

Shows the accordian with all tabs collapsed. Let me know if this works for you or if you have found another solution. Thanks.

like image 8
John Brown Avatar answered Nov 11 '22 21:11

John Brown