Primefaces 对话框始终可见

Primefaces dialog is always visible

我正在尝试通过对话框框架在单击命令按钮时打开弹出窗口。问题是 primefaces 对话框总是可见的。求助,我是不是哪里做错了。

It looks like ...

问题是立即显示数据。

面孔-config.xml:

    <application>
       <action-listener>org.primefaces.application.DialogActionListener</action-listener>
        <navigation-handler>org.primefaces.application.DialogNavigationHandler</navigation-handler>
        <view-handler>org.primefaces.application.DialogViewHandler</view-handler>
    </application>

这是我的代码。

<!DOCTYPE html>
<html  xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui">

<body>

<h:form>
     <h:panelGrid columns="1" cellpadding="5">
    <p:commandButton value="Basic" type="button" onclick="PF('dlg1').show();" />

    <p:commandButton value="Modal" type="button" onclick="PF('dlg2').show();" />

    <p:commandButton value="Effects" type="button" onclick="PF('dlg3').show();" /> 
</h:panelGrid>

<p:dialog header="Basic Dialog" widgetVar="dlg1" minHeight="40">
    <h:outputText value="Resistance to PrimeFaces is futile!" />
</p:dialog>

<p:dialog header="Modal Dialog" widgetVar="dlg2" modal="true" height="100">
    <h:outputText value="This is a Modal Dialog." />
</p:dialog>   

<p:dialog header="Effects" widgetVar="dlg3" showEffect="explode" hideEffect="bounce" height="100">
    <h:outputText value="This dialog has nice effects." />
</p:dialog>


</h:form>

</body>
</html>

您可以删除 faces-config.xml,它仅适用于对话框框架 http://www.primefaces.org/showcase/ui/df/basic.xhtml

贾昆·赫加尔说得对,你需要 <h:head><h:body>。这是一个完整的例子。

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui">
<h:head>
    <title>Dialog Example</title>
</h:head>
<h:body>

    <h:form>
        <h:panelGrid columns="1" cellpadding="5">
            <p:commandButton value="Basic" type="button"
                onclick="PF('dlg1').show();" />

            <p:commandButton value="Modal" type="button"
                onclick="PF('dlg2').show();" />

            <p:commandButton value="Effects" type="button"
                onclick="PF('dlg3').show();" />
        </h:panelGrid>

        <p:dialog header="Basic Dialog" widgetVar="dlg1" minHeight="40">
            <h:outputText value="Resistance to PrimeFaces is futile!" />
        </p:dialog>

        <p:dialog header="Modal Dialog" widgetVar="dlg2" modal="true"
            height="100">
            <h:outputText value="This is a Modal Dialog." />
        </p:dialog>

        <p:dialog header="Effects" widgetVar="dlg3" showEffect="explode"
            hideEffect="bounce" height="100">
            <h:outputText value="This dialog has nice effects." />
        </p:dialog>


    </h:form>
</h:body>
</html>