0

I have a confirmDialog and I need to do some action when the dialog is canceled. I've attached that action to 'close' button, but I need to do that also when user click 'x' icon in the top corner. How to do that?

I've tried ajax listener:

<p:confirmDialog appendToBody="true">
    <p:ajax event="close" onstart="myAction()"/> 
</p:confirmDialog>  

but I've got an error:

Unable to attach to non-ClientBehaviorHolder parent

Johny T Koshy
  • 3,857
  • 2
  • 23
  • 40
Web Devie
  • 1,207
  • 1
  • 13
  • 30
  • 1
    p:confirmDialog is an implementation of UIPanel. http://www.primefaces.org/docs/api/4.0/org/primefaces/component/confirmdialog/ConfirmDialog . f:ajax cant be nested in it. Also see, http://stackoverflow.com/questions/3539992/fajax-unable-to-attach-fajax-to-non-clientbehaviorholder-parent – Johny T Koshy Dec 04 '13 at 12:47

1 Answers1

1

What you want cannot be done, as in, it's not supported by JSF (not just primefaces).

The <p:confirmDialog/>is not a ClientBehaviourHolder(components that support listening for actions on the client side). You should just disable the X close button, forcing the user to click on either the Yes or No buttons. To disable the X:

 <p:confirmDialog id="theDialog" closable="false"/>

Or you could spring for the <p:dialog/>, which provides support for listeners

Further reading:

Community
  • 1
  • 1
kolossus
  • 20,559
  • 3
  • 52
  • 104