Primefaces 对话框框架:对话框未打开
Primefaces Dialog Framework: Dialog not opening
我正在使用对话框框架在单击命令时打开一个新的 xhtml 页面 link。
问题是执行了打开对话框的代码,但没有任何反应。
调用新对话框的 XHTML 代码。
<h:outputScript name="jquery/jquery-plugins.js" library="primefaces"/>
<h:outputScript name="jquery/jquery.js" library="primefaces"/>
<p:commandLink value="Create Customer">
<p:ajax event="click" listener="#{bookingController.createCustomer}" />
</p:commandLink>
在BookingController.java
中调用了方法
public void createCustomer()
{
// showMessageInDialog works fine but openDialog doesnt,
// RequestContext.getCurrentInstance().showMessageInDialog(new FacesMessage(FacesMessage.SEVERITY_INFO,
// "What we do in life", "Echoes in eternity."));
Map<String, Object> options = new HashMap<String, Object>();
options.put("modal", true);
options.put("draggable", false);
options.put("resizable", false);
options.put("contentWidth", 500);
options.put("contentHeight", 100);
options.put("includeViewParams", true);
RequestContext.getCurrentInstance().openDialog("/test",options,null);
// Tried below also.
// RequestContext.getCurrentInstance().openDialog("test",options,null);
// RequestContext.getCurrentInstance().openDialog("/hms/test",options,null);
}
test.xhtml 在根 webapp 文件夹下
<!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>Cars</title>
<h:outputScript name="jquery/jquery-plugins.js" library="primefaces"/>
<h:outputScript name="jquery/jquery.js" library="primefaces"/>
</h:head>
<h:body>
<h:outputText value="Hi" />
</h:body>
</html>
面孔-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>
此致,
卡皮尔
primefaces 5.1
莫哈拉 2.2.8
wildfly-8.2.0.Final
Pastor 在上面的评论中回答:
我将 ajax
事件侦听器更改为 commandLink actionListener
<p:commandLink value="Create Customer">
<p:ajax event="click" listener="#{bookingController.createCustomer}" />
</p:commandLink>
到
<p:commandLink value="Create Customer" actionListener="#bookingController.createCustomer}">
您是否将 listener="#{bookingController.createCustomer}" 更改为 actionListener="#{bookingController.createCustomer}" ?
<p:commandLink value="Create Customer">
<p:ajax event="click" listener="#{bookingController.createCustomer}"/>
</p:commandLink>
至
<p:commandLink value="Create Customer" actionListener="#bookingController.createCustomer}">
我正在使用对话框框架在单击命令时打开一个新的 xhtml 页面 link。 问题是执行了打开对话框的代码,但没有任何反应。
调用新对话框的 XHTML 代码。
<h:outputScript name="jquery/jquery-plugins.js" library="primefaces"/>
<h:outputScript name="jquery/jquery.js" library="primefaces"/>
<p:commandLink value="Create Customer">
<p:ajax event="click" listener="#{bookingController.createCustomer}" />
</p:commandLink>
在BookingController.java
中调用了方法public void createCustomer()
{
// showMessageInDialog works fine but openDialog doesnt,
// RequestContext.getCurrentInstance().showMessageInDialog(new FacesMessage(FacesMessage.SEVERITY_INFO,
// "What we do in life", "Echoes in eternity."));
Map<String, Object> options = new HashMap<String, Object>();
options.put("modal", true);
options.put("draggable", false);
options.put("resizable", false);
options.put("contentWidth", 500);
options.put("contentHeight", 100);
options.put("includeViewParams", true);
RequestContext.getCurrentInstance().openDialog("/test",options,null);
// Tried below also.
// RequestContext.getCurrentInstance().openDialog("test",options,null);
// RequestContext.getCurrentInstance().openDialog("/hms/test",options,null);
}
test.xhtml 在根 webapp 文件夹下
<!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>Cars</title>
<h:outputScript name="jquery/jquery-plugins.js" library="primefaces"/>
<h:outputScript name="jquery/jquery.js" library="primefaces"/>
</h:head>
<h:body>
<h:outputText value="Hi" />
</h:body>
</html>
面孔-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>
此致, 卡皮尔
primefaces 5.1 莫哈拉 2.2.8 wildfly-8.2.0.Final
Pastor 在上面的评论中回答:
我将 ajax
事件侦听器更改为 commandLink actionListener
<p:commandLink value="Create Customer">
<p:ajax event="click" listener="#{bookingController.createCustomer}" />
</p:commandLink>
到
<p:commandLink value="Create Customer" actionListener="#bookingController.createCustomer}">
您是否将 listener="#{bookingController.createCustomer}" 更改为 actionListener="#{bookingController.createCustomer}" ?
<p:commandLink value="Create Customer">
<p:ajax event="click" listener="#{bookingController.createCustomer}"/>
</p:commandLink>
至
<p:commandLink value="Create Customer" actionListener="#bookingController.createCustomer}">