无法使PrimeFaces RequestContext.getCurrentInstance().openDialog()工作 [英] Can't get PrimeFaces RequestContext.getCurrentInstance().openDialog() to work

查看:405
本文介绍了无法使PrimeFaces RequestContext.getCurrentInstance().openDialog()工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无法使PrimeFaces RequestContext.getCurrentInstance().openDialog()正常工作.我将示例代码从primefaces展示柜中取出,但没有打开对话框.我正在使用在Wildfly 8.2.0.Final上运行的PF 5.1.有什么想法吗?

Can't get PrimeFaces RequestContext.getCurrentInstance().openDialog() to work. I lifted the example code right out of the primefaces showcase, but I never get a dialog to open up. I'm using PF 5.1 running on Wildfly 8.2.0.Final. Any ideas what's up?

DFView.java

DFView.java

@ManagedBean(name = "dfView")
public class DFView {

    public void chooseCar() {
        RequestContext.getCurrentInstance().openDialog("selectCar");
    }

    public void onCarChosen(SelectEvent event) {
        Car car = (Car) event.getObject();
        FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Car Selected", "Id:" + car.getId());
        FacesContext.getCurrentInstance().addMessage(null, message);
    }
}

和我的dialogplay.xhtml

and my dialogplay.xhtml

<!DOCTYPE html>
<ui:composition xmlns="http://www.w3.org/1999/xhtml" template="/WEB-INF/templates/template.xhtml"
  xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:h="http://xmlns.jcp.org/jsf/html"
  xmlns:p="http://primefaces.org/ui">
  <ui:define name="body">
<h:form>
    <p:growl id="growl" showDetail="true" />

    <p:commandButton value="Select Car" icon="ui-icon-extlink" actionListener="#{dfView.chooseCar}">
        <p:ajax event="dialogReturn" listener="#{dfView.onCarChosen}" update="growl" />
    </p:commandButton>
</h:form>
  </ui:define>
</ui:composition>

推荐答案

请在您的faces-config中检查"selectCar"是否为有效的导航规则,该规则引用了dialogplay.xhtml. (或使用wittakarn的解决方案,这更容易)

Please check "selectCar" is a valid Navigation Rule in your faces-config which references dialogplay.xhtml. (or use wittakarn's solution, which is easier)

如果是这种情况,请检查您的faces-config是否包含Dialog Framework配置(Primefaces 5.1用户指南中的第519页,很容易错过):

If that is the Case, check that your faces-config contains the Dialog Framework Configuration (Page 519 in the Primefaces 5.1 Users Guid, it's easy to miss):

<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 RequestContext.getCurrentInstance().openDialog()工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆