【发布时间】:2014-05-31 11:31:25
【问题描述】:
我在 h:form 中的 ui:composition 中有一个菜单栏。命令按钮应该调用一个 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 是会话范围的并且是实例化的。
调用这个组件的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
【问题讨论】:
-
发布您的 managedbean 代码。
-
问题是由@ali所说的commandButton上的type="button"引起的
标签: jsf jakarta-ee primefaces xhtml