From a9ae3b86525ceba57087f9d19d948955f8ff4767 Mon Sep 17 00:00:00 2001 From: hengsin Date: Wed, 25 Jan 2023 20:17:47 +0800 Subject: [PATCH] IDEMPIERE-5520 Navigation between Tabs leave Detached DOM objects (Leak) (#1647) - Find find window error (duplicate id) --- .../webui/adwindow/AbstractADWindowContent.java | 12 ++++++++++-- .../src/org/adempiere/webui/window/FindWindow.java | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java index 812afc4794..20ca4f6904 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java @@ -33,6 +33,7 @@ import java.util.Map; import java.util.Properties; import java.util.TreeMap; import java.util.logging.Level; +import java.util.stream.Collectors; import org.adempiere.exceptions.DBException; import org.adempiere.util.Callback; @@ -1981,7 +1982,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements int record_ID = adTabbox.getSelectedGridTab().getRecord_ID(); if (adTabbox.getSelectedGridTab().getTabLevel() == 0 && record_ID != masterRecord) { - clenFindWindowHashMap(); + cleanFindWindowHashMap(); masterRecord = record_ID; } @@ -4119,8 +4120,15 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements * Clean all the detail cached FindWindow objects * when the master record is changed */ - private void clenFindWindowHashMap() { + private void cleanFindWindowHashMap() { + List list = tabFindWindowHashMap.entrySet().stream().filter(e -> e.getKey().getTabLevel() != 0) + .map(Map.Entry::getValue) + .collect(Collectors.toList()); tabFindWindowHashMap.keySet().removeIf(tab -> tab.getTabLevel() != 0); + if (!list.isEmpty()) { + list.forEach(e -> AEnv.detachInputElement(e)); + Executions.schedule(getComponent().getDesktop(), e -> list.forEach(f -> f.detach()), new Event("onDetachCacheFindWindow")); + } } private void clearTitleRelatedContext() { 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 02ad5d8d4d..14858da589 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 @@ -349,7 +349,7 @@ public class FindWindow extends Window implements EventListener, ValueCha this.setMaximizable(false); this.setWidgetAttribute(AdempiereWebUI.WIDGET_INSTANCE_NAME, "findWindow"); - this.setId("findWindow_"+targetWindowNo); + this.setId("findWindow_"+targetWindowNo+"_"+targetTabNo); LayoutUtils.addSclass("find-window", this); addEventListener(Events.ON_CANCEL, e -> onCancel());