这是我在一个数据表列中的commandButton,其作用是删除关联的行对象:
<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>
我希望发布的名称显示在删除确认消息中(您确定要删除版本&#34; XYZ&#34;?)..但问题是版本的名称&#34; XYZ&#34;在消息中既不显示也不在<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。
它没有工作......
答案 0 :(得分:0)
如果你不介意一些额外的代码行,那么你可以实现如下,
首先放置一个对话框的数据表
<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();
}
然后在datatable删除按钮
<p:commandButon type="button"
value="Delete"
onclick="confirm(#{release.id},'#{release.name}')" />