Q:

Richfaces popup panel

How can I invoke a method from backing bean before popup panel shows?
<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>

In this case doSomething() method doesn't invoke. 

A:

Nest a4j:ajax in the commandButton or use a4j:commandButton. These two components have an oncomplete attribute where you could put a code that opens the popup dialog like this:
<a4j:commandButton value="Call the popup" action="#{bean.doSomething}" oncomplete="#{rich:component('popup')}.show()">
</a4j:commandButton>

This will perform an ajax request when the button is clicked and will open the popup when the request is finished.

