Jsf ManagedBean中的调用对话框现在显示PrimeFaces 5

Jsf ManagedBean中的调用对话框现在显示PrimeFaces 5,jsf,primefaces,dialog,Jsf,Primefaces,Dialog,我需要做的是从ManagedBean调用I对话框,与此示例完全相同: 它看起来很简单,但我是JSF新手,可能showcase认为我应该知道一些东西来让它工作 我所做的与showCase非常相似: 文件myDialog.xhtml <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://pri

我需要做的是从ManagedBean调用I对话框,与此示例完全相同:

它看起来很简单,但我是JSF新手,可能showcase认为我应该知道一些东西来让它工作

我所做的与showCase非常相似:

文件myDialog.xhtml

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui">
<h:head>
    <title>Dialog Test</title>
    <style type="text/css">
.ui-widget {
    font-size: 90%;
}
</style>
</h:head>
<h:body>
    <h1>Dialog Working</h1>
</h:body>
</html>

对话测试
.ui小部件{
字体大小:90%;
}
对话工作
在“客户端”页面中:


公开作废{
RequestContext.getCurrentInstance().openDialog(“myDialog”);
}
当我尝试调用对话框时,什么都没有发生

在Firebug控制台中,我得到了“用于var的Widget'Widget\u frmody\u j\u idt88'不可用!”

我注意到showCase中的.xhtml文件没有可用性,因此我尝试了以下方法:

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

    <p:dialog widgetVar="testDialog">
        <h1>This is a Dialog</h1>

    </p:dialog>

</html>

RequestContext rc = RequestContext.getCurrentInstance();
rc.execute("PF('testDialog').show()");

这是一个对话
RequestContext rc=RequestContext.getCurrentInstance();
rc.execute(“PF('testDialog').show()”);
我得到:

TypeError:PF(…)未定义jquery.js:1 “变量'testDialog'的小部件不可用!”


我该怎么做才能让它工作呢?

这是我给你的例子

XHTML


对话框xhtml页面应该分开,还是可以在一个大xhtml页面的内部?@SajjadHTLO您可以在一个大xhtml页面的内部使用p:dialog。但是,我建议您将p:dialog分离到另一个页面,并包括到您的大xhtml页面。
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui">

    <p:dialog widgetVar="testDialog">
        <h1>This is a Dialog</h1>

    </p:dialog>

</html>

RequestContext rc = RequestContext.getCurrentInstance();
rc.execute("PF('testDialog').show()");
<h:form>
    <h:panelGrid columns="1" cellpadding="1">
        <p:commandButton value="Basic" 
                         process="@this" 
                         update="@form" 
                         actionListener="#{dialogView.openDialog}"/>
    </h:panelGrid>

    <p:dialog header="Basic Dialog" 
              widgetVar="dlg1" 
              minHeight="40">
        <h:outputText value="Dialog open!" />
    </p:dialog>
</h:form>
public void openDialog() {
    RequestContext rc = RequestContext.getCurrentInstance();
    rc.execute("PF('dlg1').show()");
}