3

我曾经使用 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>确认对话框中设置 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> 
4

1 回答 1

1

您也可以通过 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>       
于 2013-06-19T11:29:55.210 回答