0
我需要做的叫我从ManagedBean对话框,正是这样出现在: http://www.primefaces.org/showcase/ui/df/basic.xhtml呼叫对话框现在显示PrimeFaces 5
它看起来很琐碎,但我是新来的JSF,也许有展示柜假设我应该知道使之发挥作用。
我所做的是非常相似案例:
文件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>
在该页面的 “客户” 页面:
<p:commandButton value="Open Dialog" ajax="true"
actionListener="#{testMB.open}"
/>
public void open() {
RequestContext.getCurrentInstance().openDialog("myDialog");
}
当我尝试调用对话框什么都没发生!
在Firebug控制台中,我得到了“Widget的widget'widget_frmBody_j_idt88'不可用!”
我注意到从展示.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()");
而且我得到了:
类型错误:PF(...)是不确定的jquery.js :1 “Widget for var'testDialog'not available!”
我该怎么做才能使它工作?
应该对话框XHTML页面分开,也可以是内大XHTML页面的? – 2015-04-08 09:27:09
@SajjadHTLO你可以使用p:对话框将分隔页面和嵌套在大型xhtml页面的内部。不过,我建议您将p:对话框分隔到另一页,并包含到您的大型xhtml页面。 – wittakarn 2015-04-09 01:54:50