From 61cb022c417ca48e6285116804523d8d6f65332f Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Wed, 26 Mar 2014 20:41:39 +0800 Subject: [PATCH] 1003875 From server log - Fixed NPE in AbstractDesktop. --- .../webui/desktop/AbstractDesktop.java | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/AbstractDesktop.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/AbstractDesktop.java index 38ed19fc41..9964c940f7 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/AbstractDesktop.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/AbstractDesktop.java @@ -26,6 +26,7 @@ import org.adempiere.webui.part.AbstractUIPart; import org.compiere.model.MMenu; import org.compiere.util.CLogger; import org.compiere.util.Env; +import org.zkoss.zk.ui.Desktop; import org.zkoss.zk.ui.Executions; import org.zkoss.zk.ui.Session; import org.zkoss.zk.ui.event.Event; @@ -122,7 +123,7 @@ public abstract class AbstractDesktop extends AbstractUIPart implements IDesktop */ public void unregisterWindow(int WindowNo) { List windows = getWindows(); - if (WindowNo < windows.size()) + if (windows != null && WindowNo < windows.size()) windows.set(WindowNo, null); Env.clearWinContext(WindowNo); } @@ -134,7 +135,7 @@ public abstract class AbstractDesktop extends AbstractUIPart implements IDesktop */ public Object findWindow(int WindowNo) { List windows = getWindows(); - if (WindowNo < windows.size()) + if (windows != null && WindowNo < windows.size()) return windows.get(WindowNo); else return null; @@ -299,14 +300,19 @@ public abstract class AbstractDesktop extends AbstractUIPart implements IDesktop } protected List getWindows(){ - Session session = getComponent().getDesktop().getSession(); - @SuppressWarnings("unchecked") - List list = (List) session.getAttribute("windows.list"); - if (list == null) { - list = new ArrayList(); - session.setAttribute("windows.list", list); + Desktop desktop = getComponent().getDesktop(); + if (desktop != null) { + Session session = desktop.getSession(); + @SuppressWarnings("unchecked") + List list = (List) session.getAttribute("windows.list"); + if (list == null) { + list = new ArrayList(); + session.setAttribute("windows.list", list); + } + return Collections.synchronizedList(list); + } else { + return null; } - return Collections.synchronizedList(list); } }