I am looking for a way to properly handle pop-up dialog close events.
I have OK and Cancel buttons. When OK is selected, actionListener and action are executed. Depending on the result of action, I would like to either: 
- Close the dialog.
- Stay in the dialog and display error or warning message.
Currently I can only do the 1st case with this code:
<p:commandButton 
    id="btnOkId" 
    value="OK" 
    ajax="true" 
    type="submit" 
    actionListener="#{WatchfolderEditBean.save}" 
    action="#WatchfolderMgmtBean.refreshList}" 
    oncomplete="dlgEditWF.hide();" 
    update=":wfMgtForm:wfTable :editWFForm:messagesId"/>
What is the proper way of doing it to be able to stay in the dialog in case action reports some kind of error? 
