【问题标题】:Open p:confirmDialog on clicking of p:commandLink点击 p:commandLink 打开 p:confirmDialog
【发布时间】:2012-11-15 10:43:45
【问题描述】:

我试图在单击 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>

我怎样才能让对话框以这种方式保持打开状态?

PrimeFace ShowCase 中,该示例处理 CommandButton 并且可以正常工作,但我的要求是使用 CommandLink。

有可能吗?任何指针都会对我很有帮助。

【问题讨论】:

  • 您的 code-sn-p 对我有用 .. 错误可能在其他地方?
  • 可能是 JS 错误。阅读浏览器 JS 控制台以获取线索。顺便说一句,在此构造中完全不需要命令链接(假设您没有过度简化代码)。只需使用普通链接即可。

标签: java jsf dialog primefaces commandlink


【解决方案1】:

使用

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

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

这样你可以避免提交

【讨论】:

  • 第一个对我有用.. 谢谢@Kerem Baydogan
猜你喜欢
  • 1970-01-01
  • 2015-08-20
  • 2014-12-15
  • 2018-01-01
  • 1970-01-01
  • 2015-09-11
  • 2018-05-06
  • 2013-06-10
  • 1970-01-01
相关资源
最近更新 更多