2

I have got an issue with my confirmation dialog. It just does not close after clicking the confirm-button. This only occurs, if my form is in a tab view. (Excatly the some code works fine, if my form is not in a tab view but only a panel or something like that.)

        <h:form id="timingTableForm">
            <p:dataTable var="item" value="#{requestBean.rmRequest.timingList}" id="timingDataTable" editable="true">
             // some dataTable 
            </p:dataTable>
            <p:confirmDialog closable="true" appendToBody="true" id="confirmDialog" message="#{msg.conf_deleteyesno}" header="#{msg.conf_header}" severity="alert" widgetVar="confirmation">  
                <p:commandButton id="confirm" value="#{msg.btn_yessure}" update="timingTableForm" oncomplete="confirmation.hide()" actionListener="#{requestBean.deleteTiming}" process="@this"/>  
                <p:commandButton id="decline" value="#{msg.btn_notyet}" onclick="confirmation.hide()" type="button" />   
            </p:confirmDialog>
        </h:form>

If I change "oncomplete" to "onclick" it works fine also, but I want the dialog to disapear not until the server side operation is finished.

When I push the confirm-button something strange happens within the resulting HTML:

<div id="mainTabView:timingTableForm:confirmDialog" class="ui-confirm-dialog ui-dialog ui-widget ui-widget-content ui-overlay-hidden ui-corner-all ui-shadow" style="width: auto; height: auto;">

<div id="mainTabView:timingTableForm:confirmDialog" class="ui-confirm-dialog ui-dialog ui-widget ui-widget-content ui-corner-all ui-shadow ui-overlay-visible" style="width: auto; height: auto; left: 994.5px; top: 186px; visibility: visible; z-index: 1006;">

A new div with the same ID as my confirm-dialog is rendered. The result is one hidden confirm diolog (as expected) but there is also a new dialog that is still visible. If i push the confirm button again I have 2 hidden conform dialogs and 1 visible dialog and so on...

Am I doing something wrong? Can you spot any error? Or could this be a bug in primefaces?

  • Primefaces 3.4.1
  • Running on GlassFish 3.1.2
  • Browser Firefox 16.0.2

Thank you in advance, Fant


Actually i found a solution for my problem:

The problem only occurs, if I try to update the whole form which also contains the confirm dialog. If I only update some specific areas in this form, it works fine.

4

1 回答 1

6

对话框不应放置在任何表单内,而应放置在任何表单外并拥有自己的表单。

<h:form id="timingTableForm">
    <p:dataTable var="item" value="#{requestBean.rmRequest.timingList}" id="timingDataTable" editable="true">
     // some dataTable 
    </p:dataTable>
</h:form>

<p:confirmDialog closable="true" appendToBody="true" id="confirmDialog" message="#{msg.conf_deleteyesno}" header="#{msg.conf_header}" severity="alert" widgetVar="confirmation">  
    <h:form>
        <p:commandButton id="confirm" value="#{msg.btn_yessure}" update="timingTableForm" oncomplete="confirmation.hide()" actionListener="#{requestBean.deleteTiming}" process="@this"/>  
        <p:commandButton id="decline" value="#{msg.btn_notyet}" onclick="confirmation.hide()" type="button" />   
    </h:form>
</p:confirmDialog>

这是因为对话框的 HTML 表示可能在真实的 HTML DOM 树中移动到当前表单之外(正如您明确所做的那样appendToBody="true"),这可能会导致异步请求和更新期间的“wtf”行为,正如您所经历的那样。

于 2012-11-23T17:31:19.627 回答