0
votes

I have a menu bar called in a ui:composition within a h:form. The command button should call a bean method to logout but it fails.

The code looks like this (this page is header.xhtml):

<ui:composition 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"
xmlns:p="http://primefaces.org/ui">

  <h:form id="headerForm">
    <p:menubar>

        <f:facet name="options">
            <h:outputText value="#{bean.helloMessage}"/>
            <p:spacer width="5"/>
            <p:commandButton type="button" value="Logout" icon="ui-icon-extlink"
                             style="font-size: 16px;"
                             action="#{bean.doLogout()}"/>
        </f:facet>
    </p:menubar>
 </h:form>
</ui:composition>

Note that the bean I called is session scoped and is instanciated.

The xhtml page that calls this component looks like this

<h:body>
<div id="header">
    <ui:insert name="header" >
        <ui:include src="/common/header.xhtml" />
    </ui:insert>
</div>
<div id="body">
    <ui:insert name="body">
        <div id="menu">
            <ui:insert name="menu">
                <ui:include src="/common/menu.xhtml" />
            </ui:insert>
        </div>
        <div id="content">
            <ui:insert name="content" />
        </div>
    </ui:insert>
</div>
</h:body>

Also, content has a form within it. Could you please help me :) thanks

Primefaces version 5.0 Faces version 2.1.11

1
post your managedbean code. - Makky
the problem is caused by type="button" on the commandButton as @ali said - DKN

1 Answers

1
votes
<p:commandButton value="Logout" icon="ui-icon-extlink"
                             style="font-size: 16px;"
                             action="#{bean.doLogout()}"/>

you must delete attribut type, is work :)