From 560b9f4bad05b7138131e7f8a66cf65ea68745f4 Mon Sep 17 00:00:00 2001 From: hengsin Date: Wed, 1 Feb 2023 19:03:39 +0800 Subject: [PATCH] IDEMPIERE-5520 Navigation between Tabs leave Detached DOM objects (Leak) (#1658) IDEMPIERE-5559 Cannot find current Find Window - NullPointerException - Fix navigation error --- .../org/adempiere/webui/component/Window.java | 21 ++++++++++++++++++- .../adempiere/webui/window/FindWindow.java | 4 ++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/Window.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/Window.java index 79ab1ffa39..223ae69092 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/Window.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/Window.java @@ -62,6 +62,8 @@ public class Window extends org.zkoss.zul.Window implements ISupportMask /*** Replace current tab content ***/ public static final String REPLACE = "replace"; + private boolean fireWindowCloseEventOnDetach = true; + public Window() { super(); @@ -83,7 +85,8 @@ public class Window extends org.zkoss.zul.Window implements ISupportMask super.onPageDetached(page); if (Executions.getCurrent() != null && Executions.getCurrent().getDesktop() != null && Executions.getCurrent().getDesktop().getExecution() != null) { - Events.sendEvent(this, new Event(DialogEvents.ON_WINDOW_CLOSE, this, null)); + if (fireWindowCloseEventOnDetach) + Events.sendEvent(this, new Event(DialogEvents.ON_WINDOW_CLOSE, this, null)); } } @@ -146,4 +149,20 @@ public class Window extends org.zkoss.zul.Window implements ISupportMask public Component getMaskComponent() { return showMaskWrapper.getMaskComponent(); } + + /** + * + * @return true if {@link DialogEvents#ON_WINDOW_CLOSE} event is fire when window is detach from page + */ + public boolean isFireWindowCloseEventOnDetach() { + return fireWindowCloseEventOnDetach; + } + + /** + * + * @param fireWindowCloseEventOnDetach true to fire {@link DialogEvents#ON_WINDOW_CLOSE} event when window is detach from page (default is true) + */ + public void setFireWindowCloseEventOnDetach(boolean fireWindowCloseEventOnDetach) { + this.fireWindowCloseEventOnDetach = fireWindowCloseEventOnDetach; + } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/FindWindow.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/FindWindow.java index 14858da589..0f1e7040cc 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/FindWindow.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/FindWindow.java @@ -353,6 +353,7 @@ public class FindWindow extends Window implements EventListener, ValueCha LayoutUtils.addSclass("find-window", this); addEventListener(Events.ON_CANCEL, e -> onCancel()); + setFireWindowCloseEventOnDetach(false); } public boolean initialize() @@ -2940,6 +2941,9 @@ public class FindWindow extends Window implements EventListener, ValueCha } } + /** + * hide window and fire {@link DialogEvents#ON_WINDOW_CLOSE} event + */ public void dispose() { // Find SQL