Here is the way to do any processing before calling popup. First of all create a method in backing bean and assign this to action of "commandButton" or "commandLink". Sample signature for you method is as follows:
public void myMethod()
{
/**
* Place your processing logic here and then call showPoup method
**/
showPopup(popupId);
}
Signature of showPopup is:
public static void showPopup(String popupId)
{
FacesContext context = FacesContext.getCurrentInstance();
ExtendedRenderKitService extRenderKitSrvc =
Service.getRenderKitService(context, ExtendedRenderKitService.class);
extRenderKitSrvc.addScript(context,
"AdfPage.PAGE.findComponent('" + popupId + "').show();");
}