gpt4 book ai didi

jsf - 如何通过 `confirmDialog` 传递参数?

转载 作者:行者123 更新时间:2023-12-04 18:09:48 24 4
gpt4 key购买 nike

我以前使用 javascript 确认框,现在想切换到 PrimeFaces <p:confirmDialog> .

现在是这样工作的:

<p:commandLink id="deleteFGLinkId"
action="#FilterPresetGroupMgmtBean.delete}"
onclick="if( !confirm('Preset Group will be removed. Are you sure you want to continue?') ){return false;}"
onstart="bui.show();"
oncomplete="bui.hide();"
update=":pmForm:filterPresetTable :pmForm:messagePanel">
<f:param value="#{item.value.ID}" name="deleteID"></f:param>
<h:graphicImage alt="Delete Image" style="border: none" value="./images/x.png"/>
</p:commandLink>

我如何传递 deleteID参数以防我使用 confirmDialog ?这不起作用:

<p:commandLink onclick="confirmPGDeletePopup.show()">
<f:param value="#{item.value.ID}" name="deleteID"></f:param>
<h:graphicImage alt="Delete Image" style="border: none" value="./images/x.png"/>
</p:commandLink>

我也试过把 <f:param>进入确认对话框确定按钮,但这也不起作用。这是对话框:

<p:confirmDialog widgetVar="confirmPGDeletePopup" 
header="Confirm delete"
message="Preset Group will be removed. Are you sure you want to continue?"
severity="alert">
<p:commandButton id="confirm" value="Yes" oncomplete="confirmPGDeletePopup.hide()" action="#{PresetGroupMgmtBean.delete}" update=":pmForm:presetPanel :pmForm:messagePanel"/>
<p:commandButton id="decline" value="No" onclick="confirmPGDeletePopup.hide()" type="button" />
</p:confirmDialog>

最佳答案

也可以通过action方法传递参数。

<p:commandLink value="Some Magic" 
action="#{bean.setSelectedItemId(yourItemId)}"
ajax="true"
update="yourConfirmationDialog"
oncomplete="yourConfirmationDialogWidget.show();"/>

确认对话框:

<p:outputPanel id="yourConfirmationDialog" layout="block">
<p:confirmDialog widgetVar="yourConfirmationDialogWidget"
header="Confirm delete"
message="Are you sure you want delete the item with #{bean.selectedItemId} ?"
severity="alert">
<p:commandButton id="confirm" value="Yes" oncomplete="yourConfirmationDialogWidget.hide()" action="#{bean.delete}" />
<p:commandButton id="decline" value="No" onclick="yourConfirmationDialogWidget.hide()" type="button" />
</p:confirmDialog>
</p:outputPanel>

关于jsf - 如何通过 `confirmDialog` 传递参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17189812/

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