Richfaces弹出面板

Ven*_*nov 3 java jsf richfaces

如何在弹出面板显示之前从支持bean调用方法?

<h:commandButton value="Call the popup" action="#{bean.doSomething}" >
    <rich:componentControl target="popup" operation="show" />
</h:commandButton>

<rich:popupPanel id="popup" modal="true" resizeable="true" onmaskclick="#{rich:component('popup')}.hide()">
   ...
</rich:popupPanel>
Run Code Online (Sandbox Code Playgroud)

在这种情况下,doSomething()方法不会调用.

Adr*_*tev 6

a4j:ajaxcommandButton或使用a4j:commandButton.这两个组件有一个oncomplete属性,您可以在其中放置一个打开弹出对话框的代码,如下所示:

<a4j:commandButton value="Call the popup" action="#{bean.doSomething}" oncomplete="#{rich:component('popup')}.show()">
</a4j:commandButton>
Run Code Online (Sandbox Code Playgroud)

这将在单击按钮时执行ajax请求,并在请求完成时打开弹出窗口.