[ 2653441 ] Browser reload button crash window with included tab
This commit is contained in:
parent
735e61778a
commit
83566cc130
|
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
package org.adempiere.webui;
|
package org.adempiere.webui;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
@ -30,6 +32,7 @@ import org.compiere.model.MSysConfig;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Language;
|
import org.compiere.util.Language;
|
||||||
|
import org.zkoss.zk.ui.Component;
|
||||||
import org.zkoss.zk.ui.Executions;
|
import org.zkoss.zk.ui.Executions;
|
||||||
import org.zkoss.zk.ui.Page;
|
import org.zkoss.zk.ui.Page;
|
||||||
import org.zkoss.zk.ui.Session;
|
import org.zkoss.zk.ui.Session;
|
||||||
|
|
@ -146,16 +149,29 @@ public class AdempiereWebUI extends Window implements EventListener, IWebClient
|
||||||
ExecutionCarryOver eco = (ExecutionCarryOver) currSess.getAttribute("execution.carryover");
|
ExecutionCarryOver eco = (ExecutionCarryOver) currSess.getAttribute("execution.carryover");
|
||||||
if (eco != null) {
|
if (eco != null) {
|
||||||
//try restore
|
//try restore
|
||||||
|
try {
|
||||||
appDesktop = (IDesktop) d;
|
appDesktop = (IDesktop) d;
|
||||||
|
|
||||||
ExecutionCarryOver current = new ExecutionCarryOver(this.getPage().getDesktop());
|
ExecutionCarryOver current = new ExecutionCarryOver(this.getPage().getDesktop());
|
||||||
ExecutionCtrl ctrl = ExecutionsCtrl.getCurrentCtrl();
|
ExecutionCtrl ctrl = ExecutionsCtrl.getCurrentCtrl();
|
||||||
Visualizer vi = ctrl.getVisualizer();
|
Visualizer vi = ctrl.getVisualizer();
|
||||||
eco.carryOver();
|
eco.carryOver();
|
||||||
|
Collection<Component> rootComponents = new ArrayList<Component>();
|
||||||
try {
|
try {
|
||||||
ctrl = ExecutionsCtrl.getCurrentCtrl();
|
ctrl = ExecutionsCtrl.getCurrentCtrl();
|
||||||
ctrl.setVisualizer(vi);
|
ctrl.setVisualizer(vi);
|
||||||
|
|
||||||
|
//detach root component from old page
|
||||||
|
Page page = appDesktop.getComponent().getPage();
|
||||||
|
Collection<?> collection = page.getRoots();
|
||||||
|
Object[] objects = new Object[0];
|
||||||
|
objects = collection.toArray(objects);
|
||||||
|
for(Object obj : objects) {
|
||||||
|
if (obj instanceof Component) {
|
||||||
|
((Component)obj).detach();
|
||||||
|
rootComponents.add((Component) obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
appDesktop.getComponent().detach();
|
appDesktop.getComponent().detach();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
appDesktop = null;
|
appDesktop = null;
|
||||||
|
|
@ -165,9 +181,17 @@ public class AdempiereWebUI extends Window implements EventListener, IWebClient
|
||||||
}
|
}
|
||||||
|
|
||||||
if (appDesktop != null) {
|
if (appDesktop != null) {
|
||||||
|
//re-attach root components
|
||||||
|
for (Component component : rootComponents) {
|
||||||
|
component.setPage(this.getPage());
|
||||||
|
}
|
||||||
appDesktop.setPage(this.getPage());
|
appDesktop.setPage(this.getPage());
|
||||||
currSess.setAttribute("execution.carryover", current);
|
currSess.setAttribute("execution.carryover", current);
|
||||||
}
|
}
|
||||||
|
} catch (Throwable t) {
|
||||||
|
//restore fail
|
||||||
|
appDesktop = null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue