I am trying to open a PrimeFace ConfirmDialog on clicking of a PrimeFace CommandLink. But when the link is clicked the dialog is opened for a moment but vanishes instantly, I guess the page is being submitted. Here is the code:

<p:commandLink value="Delete" onclick="confirmation.show()"  />

<p:confirmDialog message="Are you sure, you want to delete ?"  header="Initiating deleting process"  widgetVar="confirmation">  
    <p:commandButton value="Yes Sure"  onclick="confirmation.hide()"  actionListener="#{adminCtrl.deleteUserById}" update="userData" >
        <f:attribute name="delete" value="#{user.userId}" />
    </p:commandButton>  
    <p:commandButton value="Not Yet" onclick="confirmation.hide()" type="button" />   
</p:confirmDialog>

How can I make the dialog to stay opened by this way?

In the PrimeFace ShowCase the example deals with CommandButton and that was working but my requirement is to use CommandLink.

Is it possible? Any pointer would be very helpful to me.

有帮助吗?

解决方案

Use

<p:commandLink value="Delete" onclick="confirmation.show();return false;"  />

or

<p:commandLink value="Delete" onclick="confirmation.show()" type="button"/>

this way you can avoid a submit

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top