Primefaces对话框架:对话框无法打开

时间:2015-09-08 11:44:25

标签: jsf jsf-2 primefaces

我正在使用对话框框架在点击命令链接时打开一个新的xhtml页面。 问题是打开对话框的代码已执行但没有任何反应。

调用新对话框的我的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);
}
webapp文件夹下的test.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>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>

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>

此致 卡皮尔

primefaces 5.1 Mojarra 2.2.8 wildfly-8.2.0.Final

2 个答案:

答案 0 :(得分:1)

你改变了监听器=&#34;#{bookingController.createCustomer}&#34; for actionListener =&#34;#{bookingController.createCustomer}&#34; ?

<p:commandLink value="Create Customer">
    <p:ajax event="click" listener="#{bookingController.createCustomer}"/>
</p:commandLink>

<p:commandLink value="Create Customer" actionListener="#bookingController.createCustomer}">

答案 1 :(得分:0)

牧师在上述评论中回答:

我将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}">