Dialog framework: onHide event not triggered

UI Components for JSF
Post Reply
f-matt
Posts: 1
Joined: 13 May 2020, 15:22

13 May 2020, 16:43

Hi,

I'm testing a simple example with Dialog Framework. According to the documentation, there is an "onHide" configuration option which is a "Client side callback to execute when dialog is hidden". However, I'm not getting this to work with this simple configuration (in the view component):

Code: Select all

public void openDialog() {
	Map<String,Object> options = new HashMap<String, Object>();
	options.put("onShow", "alert('df onshow')");
	options.put("onHide", "alert('df onhide')");
		
	PrimeFaces.current().dialog().openDynamic("dialog.xhtml", options, null);
}
These alerts are never shown, despite the dialog is being correctly presented and hidden. Could you give me some advice on this?

Full source code:

1) index.html

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui">

<h:head>
	<title>Index</title>
</h:head>

<h:body>
	<p:growl id="growl" showDetail="false" sticky="false">
		<p:autoUpdate />
	</p:growl>
	
	<h2>Index</h2>
	
	<h:form prependId="false">
		<p:commandButton value="DF" action="#{indexView.openDialog}" />
	</h:form>
</h:body>

</html>
2) dialog.xhtml

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html">

<h:head>
	<title>DF Dialog</title>
</h:head>

<h:body>
	<h2>DF dialog</h2>
</h:body>

</html>
3) IndexView.java

Code: Select all

package view;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import javax.faces.view.ViewScoped;
import javax.inject.Named;

import org.primefaces.PrimeFaces;


@Named
@ViewScoped
public class IndexView implements Serializable {
	
	private static final long serialVersionUID = 1L;
	
	
	public void openDialog() {
		
		Map<String,Object> options = new HashMap<String, Object>();
		options.put("onShow", "alert('df onshow')");
		options.put("onHide", "alert('df onhide')");
		
		PrimeFaces.current().dialog().openDynamic("dialog.xhtml", options, null);
		
	}
	
	
}
Environment:

Primefaces: 8.0
Mojarra 2.3.9.SP04
Wildfly: 18.0.1


Thanks in advance!

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

14 May 2020, 14:34

Looks like a bug. Dialog Framework delcares is own onHide to handle the dialog. and it doesn't look like it is calling your own onHide.

And it looks like there is this open issue: https://github.com/primefaces/primefaces/issues/2696

Code: Select all

if(!$frame.data('initialized')) {
                    PrimeFaces.cw.call(rootWindow.PrimeFaces, 'DynamicDialog', dialogWidgetVar, {
                        id: dialogId,
                        position: cfg.options.position||'center',
                        sourceFrames: sourceFrames,
                        sourceComponentId: cfg.sourceComponentId,
                        sourceWidgetVar: cfg.sourceWidgetVar,
                        onHide: function() {
                            var $dialogWidget = this,
                            dialogFrame = this.content.children('iframe');

                            if(dialogFrame.get(0).contentWindow.PrimeFaces) {
                                this.destroyIntervalId = setInterval(function() {
                                    if(dialogFrame.get(0).contentWindow.PrimeFaces.ajax.Queue.isEmpty()) {
                                        clearInterval($dialogWidget.destroyIntervalId);
                                        dialogFrame.attr('src','about:blank');
                                        $dialogWidget.jq.remove();
                                    }
                                }, 10);
                            }
                            else {
                                dialogFrame.attr('src','about:blank');
                                $dialogWidget.jq.remove();
                            }

                            rootWindow.PrimeFaces.widgets[dialogWidgetVar] = undefined;
                        },
                        modal: cfg.options.modal,
                        blockScroll: cfg.options.blockScroll,
                        resizable: cfg.options.resizable,
                        hasIframe: true,
                        draggable: cfg.options.draggable,
                        width: cfg.options.width,
                        height: cfg.options.height,
                        minimizable: cfg.options.minimizable,
                        maximizable: cfg.options.maximizable,
                        headerElement: cfg.options.headerElement,
                        responsive: cfg.options.responsive,
                        closeOnEscape: cfg.options.closeOnEscape,
                        focus: cfg.options.focus
                    });
                }
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 43 guests