Duplicate ConfirmDialog, bug?

UI Components for JSF
Post Reply
caelin
Posts: 4
Joined: 16 Nov 2010, 12:52

18 Feb 2011, 11:10

Hi,

My usecase is showing a confirm dialog for a delete yes/no. The dialog + buttons work. The dialog is shown and hidden as appropriate, and logic executed (entry deleted, growl message shown, view refreshed, etc, etc).
The problem is that the dialog creates duplicates of itself, with the same messages but without the buttons.
A new copy is created every time the dialog is shown again. So for every call to .show() an extra empty dialog is added (with the same message+header as the one with the buttons).

Is this a bug or is there an error in the way I am displaying the ConfirmDialog?


The confirm dialog is part of a composite component which provides a "DeleteButton" with the appropriate logic / properties:

Code: Select all

<p:commandButton image="#{cc.attrs.deleteButton.icon}" title="#{cc.attrs.deleteButton.name}"
			onclick="dialog.show()" disabled="#{cc.attrs.deleteButton.disabled}"
			immediate="#{cc.attrs.deleteButton.immediate}"/>
			
	<p:confirmDialog widgetVar="dialog" message="#{cc.attrs.deleteButton.dialogMessage}"
			header="#{cc.attrs.deleteButton.dialogHeader}" severity="alert"
			showEffect="fade" hideEffect="fade" closable="false">
			
			<p:commandButton value="#{cc.attrs.deleteButton.confirmButtonText}" update="@form"
				process="@form" oncomplete="dialog.hide()"
				actionListener="#{cc.attrs.deleteButton.dialogConfirmClick}" />

			<p:commandButton value="#{cc.attrs.deleteButton.cancelButtonText}" ajax="true" update="@form"
				onclick="dialog.hide()" immediate="true"/>
			
		</p:confirmDialog>
JBoss AS6 final
Mojarra 2.0.3
PrimeFaces 3.0

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

18 Feb 2011, 12:16

Do not update dialogs directly or their containers.

caelin
Posts: 4
Joined: 16 Nov 2010, 12:52

18 Feb 2011, 17:07

Thanks, your answer pointed me in the right direction. fixed it by positioning the dialog(s) in a seperate form. This still allows me to have multiple dialogs + buttons (with all different messages) and it does not update the form the dialogs are in because the rest is all seperate ajax updates (so the form with the dialogs is never "hit").

The buttons are created from a dynamic list which is why i wanted to make the dialog customizable.
JBoss AS6 final
Mojarra 2.0.3
PrimeFaces 3.0

bitec
Posts: 44
Joined: 20 Jan 2011, 21:34
Location: Russia

23 Jun 2011, 11:52

This is not convenient to my mind. Any large project has custom components, more often done by facelets. One of the frequently used examples is the component for crud datatable, allowing to delete data - the simple facelets <ui:composition>, containing p:datatable and p:confirmationDialog. In some situations we need to render some part of page with this component (imagine I have several tables and need to show only one of them on some user action using ajax). But I cannot update the panel with these tables as confirmation dialogs will be duplicated for each table.

As far as I understand the confirmation dialog renders some new javascript at the end of the page on each rendering. Is it possible to render it in its own container so that each rerendering would overwrite the javascript?

thanks
JSF: Mojarra 2.1 | PrimeFaces 2.2.1 | Glassfish 3.1

maximiliano
Posts: 18
Joined: 27 Apr 2011, 08:52

09 Jul 2011, 08:58

Optimus:
What do you mean with ' Do not update dialogs directly or their containers. ' ?
I dont understand that.
Do you mean updating confirmDialog ?
i'm not updating anything from my delete Button, and the confirmDialog still duplicated.

Code: Select all

<p:commandButton 
                                        oncomplete="confirmaEliminarRep.show()" 
                                        image="ui-icon ui-icon-close" 
                                        title="Borrar"
                                        >  
                                        <p:effect event="mouseover" type="highlight" ></p:effect>
                                        <f:setPropertyActionListener value="#{rep}" target="#{beanPJ.cliPF}" />  
                                    </p:commandButton>          			

Code: Select all

<p:confirmDialog 
                                id="confEliminarRep"
                                message="Elimina el cliente?" width="200"  
                                showEffect="explode" hideEffect="explode"
                                appendToBody="true"
                                header="Borrando #{rep.nombre}  #{rep.apellido1}" 
                                widgetVar="confirmaEliminarRep">  
                                <p:commandButton 
                                    value="Si" 
                                    update="dtRepresentantes" 
                                    actionListener="#{beanPJ.borrarRep}" 
                                    immediate="true"
                                    oncomplete="confirmaEliminarRep.hide()"
                                    />  
                                <p:commandButton 
                                    value="No"
                                    onclick="confirmaEliminarRep.hide()" 
                                    type="button" 
                                    />  
                            </p:confirmDialog>  
i'll appreciate your help. !!

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

09 Jul 2011, 09:17

Showcase sample with dialogs, confirmDialog and datatable, all in one form;

http://www.primefaces.org/showcase-labs ... Column.jsf

maximiliano
Posts: 18
Joined: 27 Apr 2011, 08:52

11 Jul 2011, 07:47

Hi Optimus
Thank you. It worked for me.
After seeing the showcase you told me.
I put my p:confirmDialog, out of my p:dialog and it worked.

Before (BAD Duplicate confirmDialog):

Code: Select all

<form>
 <p:dialog>
 <!--my inputTexts, buttons and code here -->
  <p:confirmDialog>
  </p:confirmDialog>
 </p:dialog>
</form>
After ( and working ):

Code: Select all

<form>
 <p:dialog>
    <!--my inputTexts, buttons and code here -->
 </p:dialog>
  <p:confirmDialog>
    <!--my inputTexts, buttons and code here -->
  </p:confirmDialog>
</form>
Thank you again !!! i'm happy!!!
PD: could you help me with another problem here please? i have no replies for this from 7/7/11. thanks
http://primefaces.prime.com.tr/forum/vi ... 633#p40633

Philipp
Posts: 23
Joined: 13 Oct 2011, 10:16

16 Feb 2013, 19:08

I'd still consider this a bug, it still happens with all kinds of dialogs in PF 3.5.
However, this would be easy to fix, in dialog.js in the if-block "if (cfg.appendToBody)", execute "$(document.body).children(PrimeFaces.escapeClientId(cfg.id)).remove();" before inserting the new dialog content.
Glassfish 3.1.2, PrimeFaces 3.4.2

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 26 guests