在后端异常时关闭 rich:popupPanel

Close rich:popupPanel on back-end exception

Richfaces 4.5.1
JSF 2.2
野飞 8.1.0
JDK1.8

我正在使用 a4j:commandButton 触发 bean 方法并显示 rich:popupPanel:-

<a4j:commandButton id="getReportList_btn" value="Get Report List" action="#{service.downloadReportList}" onbegin="#{rich:component('reportList_dlg')}.show()" />

service.downloadReportList Java 代码抛出的任何异常最终都会导致我使用 rich:notifyMessages.

显示的 FacesMessage

如果(且仅当)Java 代码中发生异常我想在没有任何用户交互的情况下隐藏 rich:popupPanel,立即或在 rich:notifyMessages 面板关闭后隐藏.

我怎样才能做到这一点?

使用 @data,它使 bean 属性 在 Javascript 中可用。

<a4j:commandButton id="getReportList_btn"
    value="Get Report List"
    action="#{service.downloadReportList}"
    data="#{service.downloadFailure}"
    onbegin="#{rich:component('reportList_dlg')}.show()"
    oncomplete="if(event.data)#{rich:component('reportList_dlg')}.hide()" />

因此,如果在 service.downloadReportList 期间发生异常,请将 downloadFailure 设置为 true。