Primefaces对话框始终可见



我正在尝试对话框框架在单击命令按钮时打开弹出窗口。问题是素数对话框始终可见。请帮忙,我做错了什么吗?

看起来...

问题是数据会立即显示。

faces-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

Jaqen H'ghar是对的,你需要<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>

最新更新