1
我曾經使用javascript確認框,並想切換到PrimeFaces <p:confirmDialog>
。如何通過`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>
到確認對話框OK按鈕,但沒有工作過。這裏是對話框:
<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'現在是從'commandLink'向下移動到'confirmDialog'。我如何將參數傳遞給對話框? – Danijel
您可以更新確認對話框並從bean中檢索參數。在action方法中,將參數傳遞給bean,並在確認對話框中的bean的更新之後得到它。 – ovonel