【问题标题】:Primefaces commandButton do not call the beanPrimefaces commandButton 不调用 bean
【发布时间】: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


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

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

【讨论】:

    猜你喜欢
    • 2012-12-26
    • 2017-02-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-16
    • 2018-04-23
    相关资源
    最近更新 更多