Dialogs gets Duplicated on update

UI Components for JSF
Post Reply
francesco.strazzullo
Posts: 54
Joined: 25 Nov 2011, 10:14

26 Nov 2011, 13:15

Hi all,
I've created a CompositeComponet formed by an inputText and a Dialog. When I Update the cc and launch the show() method I see two dialog. I have analyzed the output html and I have found two div with the same id. I have patched the file dialog.js in this way:

PrimeFaces.widget.Dialog.prototype._show = function() {
if(this.cfg.showEffect) {
var _self = this;

this.jq.show(this.cfg.showEffect, null, 'normal', function() {
_self.postShow();
});
}
else {
//display dialog
/*Begin Custom Code*/
var dlg = jQuery(this.jqId);

if(dlg.size() > 1){
dlg.last().remove();
}
this.jq = dlg;
/*End Custom Code*/
this.jq.show();

this.postShow();
}

this.focusFirstInput();
this.visible = true;
this.moveToTop();

if(this.cfg.modal)
this.enableModality();
}

Now when two dialogs are generated, one of them is removed and all seems to work correctly. Is this a bug or is intended to work this way?
Primefaces: 3.5
Mojarra: 2.1.18
Tomcat: 7.0.20

LarsD
Posts: 69
Joined: 25 Nov 2011, 22:47
Location: Dresden, Germany

26 Nov 2011, 13:34

.show() and .hide() are javascript functions which can have side effects like this. Also, in some cases this functions make popUps not working. I prefer not to use them to show a popup, instead you should show/hide them bean controlled.

example:

Code: Select all

<p:dialog widgetVar="dialog"
		visible="#{someBean.dialogVisible}">
...
</p:dialog>

...
<p:commandButton value="Show Dialog" 
action="#{someBean.showDialog}" image="ui-icon ui-icon-gear"
ajax="false" />
The method "showDialog" sets the boolean value "dialogVisible" to true and starts a page update by returning null or the navigation case for this page. After it the dialog is visible without using a single line of JavaScript code.

Lars
Last edited by LarsD on 26 Nov 2011, 13:34, edited 1 time in total.

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

26 Nov 2011, 13:34

Try 3.x and please read forum posting guide.

francesco.strazzullo
Posts: 54
Joined: 25 Nov 2011, 10:14

26 Nov 2011, 14:10

optimus.prime wrote:Try 3.x and please read forum posting guide.
Sorry Optimus! Here's my configuration

Primefaces: 3.0.M4
Mojarra: 2.1.2
Jboss: 6.0
Primefaces: 3.5
Mojarra: 2.1.18
Tomcat: 7.0.20

francesco.strazzullo
Posts: 54
Joined: 25 Nov 2011, 10:14

26 Nov 2011, 14:11

LarsD wrote:.show() and .hide() are javascript functions which can have side effects like this. Also, in some cases this functions make popUps not working. I prefer not to use them to show a popup, instead you should show/hide them bean controlled.

example:

Code: Select all

<p:dialog widgetVar="dialog"
		visible="#{someBean.dialogVisible}">
...
</p:dialog>

...
<p:commandButton value="Show Dialog" 
action="#{someBean.showDialog}" image="ui-icon ui-icon-gear"
ajax="false" />


The method "showDialog" sets the boolean value "dialogVisible" to true and starts a page update by returning null or the navigation case for this page. After it the dialog is visible without using a single line of JavaScript code.

Lars
I Cannot use your solution because i have to partially update my page. so my commandButtons has to be ajax=true
Primefaces: 3.5
Mojarra: 2.1.18
Tomcat: 7.0.20

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 22 guests