I already asked the question differently and it was answered as duplicate and the answer should be found in commandButton issue. I tried following all tipps, but in first place, the p:menuItem isn't really used in the examples and second in Debug Hints it apears that something is triggered, but I can't see what an my breakpoint at the beginning of the called method is never reached.
So I think I'm going to post way more code. This is the jsf-implementation which works:
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:h="http://java.sun.com/jsf/html">
<h:outputStylesheet library="css" name="menu.css"/>
<ul>
<li>
<h:commandLink value="Status" immediate="true"
action="status.xhtml?faces-redirect=true" />
</li>
<h:panelGroup rendered="#{aduserHandler.isAdmin}">
<li>
<h:commandLink value="Einstellungen" immediate="true"
action="parameter.xhtml?faces-redirect=true" />
</li>
</h:panelGroup>
<li>
<h:commandLink value="Abmelden" immediate="true"
action="#{aduserHandler.logout}" />
</li>
</ul>
</ui:composition>
Both methods isAdmin() and logout() are triggered and performed correctly.
This is the primefaces-implementation which isn't working:
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:h="http://java.sun.com/jsf/html">
<h:outputStylesheet library="css" name="menu.css"/>
<h:form id="menuform">
<p:growl id="messages" showDetail="true"/>
<div class="card">
<h5>Menu</h5>
<p:menu>
<p:submenu label="ATC">
<p:menuitem value="Status"
url="/atc/status.xhtml"
icon="pi pi-list"/>
</p:submenu>
<p:submenu label="KV">
</p:submenu>
<p:submenu label="Einstellung">
<p:menuitem value="Einstellungen"
url="/atc/parameter.xhtml"
icon="pi pi-cog"
rendered="#{aduserHandler.isAdmin}"/>
<p:menuitem value="Abmelden"
action="#{aduserHandler.logout}"
icon="pi-directions-alt"/>
</p:submenu>
</p:menu>
</div>
</h:form>
<h:commandLink value="Abmelden" immediate="true" action="#{aduserHandler.logout}" />
</ui:composition>
For testing purpose I even added the h:commandLink out of the first implementation but the logout() methode is in neither one of the buttons triggered. But to make it really weird, the isAdmin() methode works perfectly.
I tried menuitem with update="@form"
and update="menuform"
but neither worked.
I really want to understand how those menuitems work, because I wanted to use the possibility to code the menu in a class.
References to an own jQuery import have been deleted.
Edit: You were completely right. I've made the first attempt out of my JSF 101-Book and didn't realize that my layout.xhmtl goes like:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<h:outputStylesheet library="css" name="style.css" />
<title>Asset Tool Connector</title>
<link type="image/x-icon"
href="${facesContext.externalContext.requestContextPath}/resources/images/netzwerk.png"
rel="shortcut icon" />
</h:head>
<h:body>
<ui:insert name="header"/>
<f:event listener="#{aduserHandler.checkLoggedIn}" type="preRenderView" />
<h:form>
<div id="menu">
<ui:include src="menu.xhtml" />
</div>
<div id="main">
<ui:insert name="main"/>
</div>
</h:form>
<div id="footer">
© ATC - by 5332
</div>
</h:body>
</html>
But if I hadn't asked I had not looked anyway. Now what is better code for Primefaces? To leave the form around everything or to open a own form for every let's call it button group or function.