Primefaces commandButton不调用bean

时间:2014-05-31 11:31:26

标签: jsf java-ee primefaces xhtml

我有一个菜单栏叫做ui:h:表单中的组合。命令按钮应调用bean方法注销但它失败。

代码如下(此页面为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>

请注意,我调用的bean是会话作用域并且是instanciated。

调用此组件的xhtml页面如下所示

<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>

此外,内容中包含一个表单。 你能帮帮我:)谢谢

Primefaces 5.0版 面对版本2.1.11

1 个答案:

答案 0 :(得分:1)

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

你必须删除属性类型,工作:)