gpt4 book ai didi

jsf - 无法在删除确认对话框中显示对象详细信息

转载 作者:行者123 更新时间:2023-12-04 19:57:19 25 4
gpt4 key购买 nike

这是我在数据表列中的命令按钮,它的工作是删除关联的行对象:

   <p:column style="width:6%;text-align:center"
headerText="Delete">
<p:commandButton icon="ui-icon-close"
title="Delete release #{release.name}"
actionListener="#{releaseBean.deleteRelease(release)}"
process="@this" update=":display :form2:releaseList">
<p:confirm
header="Confirm deleting release #{release.name}"
message="Are you really sure you want to delete release #{release.name}?"
icon="ui-icon-alert" />
</p:commandButton>
</p:column>

我希望在删除确认消息中显示发布名称(Are you really sure you want to delete release "XYZ"?)。但问题是发布名称“XYZ”不是也不显示在 <p:confirm> 的标题中消息中都没有;但它显示在 <p:commandButton> 中标题。

我做错了什么?谢谢。


编辑:

我尝试修改 commandButton 并添加 setPropertyActionListener :

    <p:commandButton icon="ui-icon-close"
title="Delete release #{release.name}"
actionListener="#{releaseBean.deleteRelease(release)}"
process="@this" update=":display :form2:releaseList">
<f:setPropertyActionListener
target="#{gestionReleaseBean.selectedRelease}"
value="#{release}" />
<p:confirm
header="Confirm deleting release #{release.name}"
message="Are you really sure you want to delete release #{release.name}?"
icon="ui-icon-alert" />
</p:commandButton>

我在 bean 中添加了属性 selectedRelease它是 getter/setter。

没用...

最佳答案

如果您不介意一些额外的代码行,那么您可以按如下方式实现,

首先在数据表外放置一个对话框

<p:dialog modal="true" header="Confirm" widgetVar="wgc" >
<h:outputText id="msg" />
<h:inputHidden id="idh" value="#{releaseBean.id}" />
<p:commandButton value="Delete" action="#{bean.delete()}" />
<p:commandButton value="Cancel" type="button" onclick="PF('wgc').hide()" />
</p:dialog>

在你的 javascript 部分添加这个

function confirm(id,name){
document.getElementById('msg').innerHtml='Are you sure to delete ' + name;
document.getElementById('idh').value=id;
PF('wgc').show();
}

然后在数据表中删除按钮

<p:commandButon type="button" 
value="Delete"
onclick="confirm(#{release.id},'#{release.name}')" />

关于jsf - 无法在删除确认对话框中显示对象详细信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24755457/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com