无法获取 PrimeFacesRequestContext.getCurrentInstance().openDialog()
上班。我直接从 primefaces 展示中提取了示例代码,但我从未打开过对话框。我正在使用在 Wildfly 8.2.0.Final 上运行的 PF 5.1。有什么想法吗?
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
<!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>
请检查“selectCar”是您的 faces-config 中引用dialogplay.xhtml 的有效导航规则。 (或者使用wittakarn的解决方案,这更容易)
如果是这种情况,请检查您的 faces-config 是否包含对话框框架配置(Primefaces 5.1 用户指南中的第 519 页,很容易错过):
<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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)