Jsf Primefaces对话框关闭按钮不工作

Jsf Primefaces对话框关闭按钮不工作,jsf,primefaces,Jsf,Primefaces,我在一天内找不到解决这个问题的方法。 当我点击对话框上的关闭按钮时,它什么也不做。 我尝试添加modal=“false”,然后它就可以工作了。但在我的情况下,它应该是modal=“true”, 防止用户单击屏幕上的任何其他位置。我做错了什么? 谢谢你抽出时间 <ui:composition template="/pages/admin/admin.xhtml" xmlns="http://www.w3.org/1999/xhtml" xmln

我在一天内找不到解决这个问题的方法。 当我点击对话框上的关闭按钮时,它什么也不做。 我尝试添加modal=“false”,然后它就可以工作了。但在我的情况下,它应该是modal=“true”, 防止用户单击屏幕上的任何其他位置。我做错了什么? 谢谢你抽出时间

<ui:composition template="/pages/admin/admin.xhtml"
            xmlns="http://www.w3.org/1999/xhtml"
            xmlns:ui="http://java.sun.com/jsf/facelets"
            xmlns:f="http://java.sun.com/jsf/core"
            xmlns:h="http://java.sun.com/jsf/html"
            xmlns:p="http://primefaces.org/ui">

<ui:define name="center">
    <h:form id="form">
        <p:growl id="msgs" showDetail="true" />

        <p:dataTable id="basicDT" var="user" value="#{userSelectionViewMB.users}">
            <f:facet name="header">
                <p:outputLabel value="#{menu['menu.admin.updateuser.list']}"/>
            </f:facet>
            <p:column headerText="#{menu['menu.admin.createuser.id']}">
                <h:outputText value="#{user.id}" />
            </p:column>
            <p:column headerText="#{menu['menu.admin.createuser.name']}">
                <h:outputText value="#{user.name}" />
            </p:column>
            <p:column headerText="#{menu['menu.admin.createuser.surname']}">
                <h:outputText value="#{user.surname}" />
            </p:column>
            <p:column headerText="#{menu['menu.admin.createuser.grade']}">
                <h:outputText value="#{user.grade}" />
            </p:column>
            <p:column style="width:32px;text-align: center">
                <p:commandButton update=":form:userDetail" oncomplete="PF('userDialog').show()" icon="ui-icon-search" title="View">
                    <f:setPropertyActionListener value="#{user}" target="#{userSelectionViewMB.selectedUser}" />
                </p:commandButton>
            </p:column>
        </p:dataTable>

        <p:dialog header="User Info" widgetVar="userDialog" modal="true" showEffect="fade" closable="true"
                  closeOnEscape="true" hideEffect="fade" resizable="false">
            <p:outputPanel id="userDetail" style="text-align:center;">
                <p:panelGrid  columns="2" rendered="#{not empty userSelectionViewMB.selectedUser}" columnClasses="label,value">

                    <h:outputText value="Id:" />
                    <h:outputText value="#{userSelectionViewMB.selectedUser.id}" />

                    <h:outputText value="Name" />
                    <h:outputText value="#{userSelectionViewMB.selectedUser.name}" />

                    <h:outputText value="Surname:" />
                    <h:outputText value="#{userSelectionViewMB.selectedUser.surname}" />

                    <h:outputText value="Grade" />
                    <h:outputText value="#{userSelectionViewMB.selectedUser.grade}" />
                </p:panelGrid>
            </p:outputPanel>
        </p:dialog>
    </h:form>
</ui:define>

我尝试过以下代码:

<h:form id="form">
    <p:growl id="msgs" showDetail="true" />

    <p:commandButton update=":form:userDetail" oncomplete="PF('userDialog').show()" icon="ui-icon-search" title="View">
    </p:commandButton>

    <p:dialog header="User Info" widgetVar="userDialog" modal="true" showEffect="fade" closable="true" closeOnEscape="true" hideEffect="fade" resizable="false">
        <p:outputPanel id="userDetail" style="text-align:center;">
            <h:outputText value="Id:" />
            <h:outputText value="1" />

            <h:outputText value="Name" />
            <h:outputText value="Mister" />

            <h:outputText value="Surname:" />
            <h:outputText value="Brown" />

            <h:outputText value="Grade" />
            <h:outputText value="first" />
        </p:outputPanel>
    </p:dialog>
</h:form>


而且效果很好!也许问题不在于你发布的代码。您是否检查了页面中是否存在任何javascript错误?

删除
closable
标记属性如何?它没有解决我的问题@Omarthank your time,原因似乎来自我使用的模板,jsf警告要将所有组件放入表单中。所以我决定了我的问题。