Jsf 未调用Primefaces菜单项actionListener

Jsf 未调用Primefaces菜单项actionListener,jsf,primefaces,menuitem,Jsf,Primefaces,Menuitem,我正在使用JSF2.2和PrimeFaces4.0。 我想在调用menuItem“userSettingMenuItem”时触发actionListener。 问题是侦听器方法从未被调用 这是我的MenuBar.xhtml: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xht

我正在使用JSF2.2和PrimeFaces4.0。 我想在调用menuItem“userSettingMenuItem”时触发actionListener。 问题是侦听器方法从未被调用

这是我的MenuBar.xhtml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
    <ui:composition>
    <h:form>
        <p:menubar styleClass="affaires"
            style="position: absolute !important; bottom: 0px !important; vertical-align: bottom !important; list-style: none; width: 100%; text-align: center;">
            <p:menuitem value="#{msg['navigation_home']}" url="home.xhtml" />

            <p:menuitem value="Companies" url="companies.xhtml" />

            <p:menuitem id="messageNumber"
                value="#{taskboxMessageNumberBean.unSeenMessages} #{msg['navigation_taskbox']}"
                url="taskbox.xhtml" />

            <p:menuitem id="userSettingMenuItem"
                        value="#{loginBean.user.USER_NAME}"
                        url="user-settings.xhtml"
                        actionListener="#{userSettingBean.onClickSettingsMenuBar}"/>

            <p:submenu label="#{msg['navigation_admin']}">
                <p:menuitem value="Users" url="#" />
                <p:menuitem value="Edit Help" url="#" />
                <p:menuitem value="Edit GTC" url="#" />
            </p:submenu>

            <p:menuitem value="#{msg['navigation_help']}" url="#" />

        </p:menubar>
    </h:form>
    </ui:composition>
</h:body>
</html>

您不能同时拥有
url
actionListener
。使用
actionListener
并将用户重定向到
user settings.xhtml
,最后使用如下方法:

FacesContext.getCurrentInstance().getExternalContext().redirect("user-settings.xhtml");

您不能同时拥有
url
actionListener
。使用
actionListener
并将用户重定向到
user settings.xhtml
,最后使用如下方法:

FacesContext.getCurrentInstance().getExternalContext().redirect("user-settings.xhtml");

您必须添加一个操作,而不是url或结果,然后添加actionListener。例如:

action="/user-settings.xhtml?faces-redirect=true"
actionListener="#{userSettingBean.onClickSettingsMenuBar}"

您必须添加一个操作,而不是url或结果,然后添加actionListener。例如:

action="/user-settings.xhtml?faces-redirect=true"
actionListener="#{userSettingBean.onClickSettingsMenuBar}"