Reputation: 3548
I can make a p:confirm for a button that has an action, but when it's an onclick instead of an action-attribute, then clicking "Yes" in the dialog does nothing. Any tips how to make this work?
This works:
<p:commandButton action="#{customEditorBean.save}"
value="Save" rendered="#{customEditorBean.canSaveContent}">
<p:confirm message="Are you sure you want to save the content?" icon="ui-icon-alert" />
</p:commandButton>
This doesn't work:
<p:commandButton value="Close" onclick="PF('editorWidget').hide();">
<p:confirm message="Do you want to close the editor without saving?" icon="ui-icon-alert" />
</p:commandButton>
Upvotes: 0
Views: 5226
Reputation: 127
I use something similar for dialogue to remove an object, maybe you can interest this code
<h:form id="frmEliminar">
<p:dialog header="Eliminar Caja #{cajaBean.caja.descripcion}" widgetVar="dlgEliminar" modal="true">
<h:outputText value="¿Desea eliminar?" />
<p:commandButton value="Si" actionListener="#{cajaBean.eliminar()}" ajax="false" icon="b-ok" />
<p:commandButton value="No" onclick="dlgEliminar.hide();" icon="b-cancel" />
</p:dialog>
</h:form>
Upvotes: 0
Reputation: 13482
See something like this will work for you
<p:confirmDialog message="Are you sure about deleting this record?"
widgetVar="deleteConfirm">
<p:commandButton title="GDelYesButton"
value="Yes"
action="#{yourBean.delete}"
oncomplete="PF('deleteConfirm').hide()"
update=":growl"/>
<p:commandButton title="GDelNoButton"
value="No"
oncomplete="PF('deleteConfirm').hide()"/>
</p:confirmDialog>
It should work we are using same thing in our application as well.
Upvotes: 1