I have two primefaces panels in one form.
<p:panel id="pnlOne" widgetVar="pnlOne"> <p:ajax event="close" listener="#{createProduct.cancelAddProductCategory}"/></p:panel>'
<p:panel id=pnlTwo" widgetVar="pnlTwo"> <p:ajax event="close" listener="#{createProduct.cancelAddBrand}"/></p:panel>
I have another commandButton which will call the panel close function on its oncomplete attribute.
<p:commandButton id="btnadd" value="#{bundle.LabelSave}" update=":forminput :formcollector"
action="#{createProduct.createNew}" oncomplete="handleComplete(xhr, status, args)">
I set the success callback parameter in the backing bean as follows;
RequestContext.getCurrentInstance().addCallbackParam("success", true);
And the javascript function handleComplete as below;
function handleComplete(xhr, status, args) {
if(args.success) {
pnlOne.close();
pnlTwo.close();
} }
The problem is only one of these two panel can be closed. My purpose is to close both successively. But it doesn't work. Could it be because the first close execution in the javascript trigger an ajax request, have not complete the ajax request by the time second panel close is called? Any idea guys. Your help is very much appreciated.