两个<p:confirmdialog>在一个xhtml </p:confirmdialog>中

时间:2013-05-20 02:03:11

标签: jsf-2 primefaces xhtml

我有两个合一的xhtml。但他们两个都没有正常工作。 单击“保存”按钮时,“导入”按钮的confirmDialog出现。 当我单击“导入”按钮时,没有任何内容出现。 有什么我错过了吗?

               <td><p:commandButton type="button"
                 value="Save" id="cr1002_command_save"
                 onclick="confirmation.show()" ajax="false"
                 style="width: 80px;height: 24px">
              </p:commandButton> <p:confirmDialog id="confirmDialog"
                 message="#{msg.cr1002_prompt_confirm_save}" severity="alert"
                 widgetVar="confirmation" style="width: 70px;height: 27px">
                 <p:commandButton id="confirm" value="OK"
                    oncomplete="confirmation.hide()"
                    action="#{pc_Cr1002.doCr1002_command_saveAction}" ajax="false"
                    style="width: 80px;height: 24px" />
                 <p:commandButton id="decline" value="Cancel"
                    onclick="confirmation.hide()" type="button"
                    style="width: 80px;height: 24px" />
              </p:confirmDialog></td>
           <td></td>
           <td><p:commandButton type="button"
                 value="Import"
                 onclick="gowait('form1:cr1002_command_import')"
                 id="cr1002_command_import" ajax="false"
                 style="width: 80px;height: 24px"></p:commandButton>
                  <p:confirmDialog id="confirmDialog2"
                 message="Importing... Importing..." severity="alert"
                 widgetVar="confirmation" style="width: 70px;height: 27px">
                 <p:commandButton id="confirm2" value="OK"
                    oncomplete="confirmation.hide()"
                    action="#{pc_Cr1002.doCr1002_command_importAction}" ajax="false"
                    style="width: 80px;height: 24px" />
                 <p:commandButton id="decline2" value="Cancel"
                    onclick="confirmation.hide()" type="button"
                    style="width: 80px;height: 24px" />
              </p:confirmDialog>
           </td>

1 个答案:

答案 0 :(得分:3)

问题来自同一个widgetVar attribute,这个属性在客户端使用,它会导致客户端冲突,你应该编码如下:

<td><p:commandButton type="button"
                 value="Save" id="cr1002_command_save"
                 onclick="confirmation.show()" ajax="false"
                 style="width: 80px;height: 24px">
              </p:commandButton> <p:confirmDialog id="confirmDialog"
                 message="#{msg.cr1002_prompt_confirm_save}" severity="alert"
                 widgetVar="confirmation" style="width: 70px;height: 27px">
                 <p:commandButton id="confirm" value="OK"
                    oncomplete="confirmation.hide()"
                    action="#{pc_Cr1002.doCr1002_command_saveAction}" ajax="false"
                    style="width: 80px;height: 24px" />
                 <p:commandButton id="decline" value="Cancel"
                    onclick="confirmation.hide()" type="button"
                    style="width: 80px;height: 24px" />
              </p:confirmDialog></td>
           <td></td>
           <td><p:commandButton type="button"
                 value="Import"
                 onclick="confirmation2.show()"
                 id="cr1002_command_import" ajax="false"
                 style="width: 80px;height: 24px"></p:commandButton>
                  <p:confirmDialog id="confirmDialog2"
                 message="Importing... Importing..." severity="alert"
                 widgetVar="confirmation2" style="width: 70px;height: 27px">
                 <p:commandButton id="confirm2" value="OK"
                    oncomplete="confirmation.hide()"
                    action="#{pc_Cr1002.doCr1002_command_importAction}" ajax="false"
                    style="width: 80px;height: 24px" />
                 <p:commandButton id="decline2" value="Cancel"
                    onclick="confirmation.hide()" type="button"
                    style="width: 80px;height: 24px" />
              </p:confirmDialog>
           </td>