primefaces的对话元素不起作用

ris*_*shi 1 jsf primefaces jsf-1.2

我试图使用primefaces的对话框元素,但它不起作用.所以我尝试了在primefaces网站提供的相同代码.但该代码也无效.

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

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

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

                 <p:dialog id="basicDialog" header="Basic Dialog" widgetVar="dlg1" appendToBody="false">
                 <h:outputText value="Resistance to PrimeFaces is futile!" />
                    </p:dialog>

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

                    <p:dialog header="Effects" widgetVar="dlg3" showEffect="explode" hideEffect="bounce" height="100" appendToBody="false">
                        <h:outputText value="This dialog has nice effects." />
                    </p:dialog>
Run Code Online (Sandbox Code Playgroud)

这是我页面的标题:

    <!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:f="http://java.sun.com/jsf/core"
  xmlns:p="http://primefaces.org/ui">
Run Code Online (Sandbox Code Playgroud)

Kub*_*uba 7

尝试打开对话框,如下所示:

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

<p:commandButton id="modalDialogButton" value="Modal" onclick="dlg2.show();" type="button" process="@this" update="@none"/>
Run Code Online (Sandbox Code Playgroud)

请发布您的xhtml文件的标题,并说明您正在使用的PrimeFaces的版本.

以下电话:

PF('dlg2').show(); 
Run Code Online (Sandbox Code Playgroud)

不适用于Primefaces v3.5它可以正常运行4.0.版本4.0支持

dlg2.show();
Run Code Online (Sandbox Code Playgroud)

dlg2.hide();
Run Code Online (Sandbox Code Playgroud)

但不会很久,它将在以后的版本中弃用,所以请使用 PF('dlg2').show();