java 单击 p:commandLink 打开 p:confirmDialog

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13395844/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 12:33:25  来源:igfitidea点击:

Open p:confirmDialog on clicking of p:commandLink

javajsfdialogprimefacescommandlink

提问by Tapas Bose

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:

我试图在单击 PrimeFace CommandLink 时打开 PrimeFace ConfirmDialog。但是当点击链接时,对话框打开了一会儿但立即消失了,我猜页面正在被提交。这是代码:

<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 ShowCasethe example deals with CommandButton and that was working but my requirement is to use CommandLink.

PrimeFace ShowCase 中,示例处理 CommandButton 并且该示例有效,但我的要求是使用 CommandLink。

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

是否可以?任何指针都会对我很有帮助。

回答by Kerem Baydo?an

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

这样你就可以避免提交