<p:panelMenu>
<p:submenu label="Articoli">
<p:menuitem value="Anagrafica" action="/articoli/anagrafica" icon="ui-icon-document" ajax="false" />
<p:menuitem value="Importazione" action="/articoli/importazione" ajax="false" />
<p:menuitem value="Marchi" action="/articoli/marchi" ajax="false" />
</p:submenu>
<p:submenu label="Clienti">
<p:menuitem value="Anagrafica" action="/clienti/anagrafica" ajax="false" />
</p:submenu>
<p:submenu label="Vendite" icon="ui-icon-suitcase">
<p:menuitem value="Point Of Sale" action="/vendite/pos" ajax="false" />
</p:submenu>
<p:submenu label="Utilita" icon="ui-icon-calculator">
<p:menuitem value="TestPDF" action="#{menuController.getTestPdf()}" ajax="false" />
</p:submenu>
</p:panelMenu>
This menu shows perfectly but after a little navigation it behaves in unpredictable way.
I mean I can't control the state open / closed of each submenu so, on each menuitem click and page loading, they are expanded / collapsed randomly !
After a little search I found that panelMenu uses client cookies for saving the submenu's states, but.... isn't it supposed to manage all that automatically?
What can I do to manually control the state of each submenu?
You cannot manually control this behaviour as you can do it with the activeIndex attribute of the p:accordionPanel.
But I am facing the same problem and I found this Question on stackoverflow: Primefaces 3.4 p:panelMenu: unable to control the state of p:submenu and p:menuitem.
The conlusion is that the panelMenu would have the same state for pages in the same application directory. Having the pages in a more sophisticated folder structure you can only wrap all your current pages in "pseudo pages" and putting these pseudo pages the same folder.
So you end up having a pseudo page like this:
<h:html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
</h:head>
<h:body>
<ui:composition>
<ui:include src="/actualPagesDirectory/actualPage.xhtml" />
</ui:composition>
</h:body>
</h:html>
It is not very nice but so far the only solution I see using the primefaces panelMenu as it is.
EDIT: My conclusion was incorrect. Having the pseudo pages like this will not change the behaviour. So it is still a no for controlling the behaviour.
Additionally I found a hint on that this problem is known and will be addressed: Primefaces forum But still I cannot find that this issue was addressed in primefaces 3.5.CR1.