Open p:confirmDialog on clicking of p:commandLink

末鹿安然 提交于 2019-12-25 02:09:03

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/13395844/open-pconfirmdialog-on-clicking-of-pcommandlink

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!