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.
A dialog should not be placed inside any form, but be placed outside any form and have its own form.
This because the HTML representation of the dialog may in the real HTML DOM tree be moved outside the current form (as you explicitly did by
appendToBody="true"), which may cause “wtf” behaviour during asynchronous requests and updates, as you’re experiencing.