diff --git a/org.adempiere.ui.zk/WEB-INF/src/fi/jawsy/jawwa/zk/atmosphere/AtmosphereServerPush.java b/org.adempiere.ui.zk/WEB-INF/src/fi/jawsy/jawwa/zk/atmosphere/AtmosphereServerPush.java index b983da7fe7..71afc6ef92 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/fi/jawsy/jawwa/zk/atmosphere/AtmosphereServerPush.java +++ b/org.adempiere.ui.zk/WEB-INF/src/fi/jawsy/jawwa/zk/atmosphere/AtmosphereServerPush.java @@ -207,8 +207,8 @@ public class AtmosphereServerPush implements ServerPush { } } if (!ok) { - log.warn("Failed to resume long polling resource"); - Desktop d = desktop.get(); + Desktop d = desktop.get(); + log.warn("Failed to resume long polling resource" + (d != null ? " for desktop " + d.getId() : "")); if (d != null) { Integer count = (Integer) d.getAttribute(AdempiereWebUI.SERVERPUSH_SCHEDULE_FAILURES); if (count != null) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/AdempiereWebUI.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/AdempiereWebUI.java index 80576e0dd0..9e0153339e 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/AdempiereWebUI.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/AdempiereWebUI.java @@ -119,7 +119,9 @@ public class AdempiereWebUI extends Window implements EventListener, IWeb private ConcurrentMap m_URLParameters; public static final String SERVERPUSH_SCHEDULE_FAILURES = "serverpush.schedule.failures"; - + + private static final String ON_LOGIN_COMPLETED = "onLoginCompleted"; + public AdempiereWebUI() { this.setVisible(false); @@ -127,12 +129,16 @@ public class AdempiereWebUI extends Window implements EventListener, IWeb userPreference = new UserPreference(); // preserve the original URL parameters as is destroyed later on loging m_URLParameters = new ConcurrentHashMap(Executions.getCurrent().getParameterMap()); + + this.addEventListener(ON_LOGIN_COMPLETED, this); } public void onCreate() { this.getPage().setTitle(ThemeManager.getBrowserTitle()); + Executions.getCurrent().getDesktop().enableServerPush(true); + SessionManager.setSessionApplication(this); Session session = Executions.getCurrent().getDesktop().getSession(); @SuppressWarnings("unchecked") @@ -153,11 +159,11 @@ public class AdempiereWebUI extends Window implements EventListener, IWeb } else { - loginCompleted(); + Clients.showBusy(null); + //use echo event to make sure server push have been started when loginCompleted is call + Events.echoEvent(ON_LOGIN_COMPLETED, this, null); } - Executions.getCurrent().getDesktop().enableServerPush(true); - Executions.getCurrent().getDesktop().addListener(new DrillCommand()); Executions.getCurrent().getDesktop().addListener(new TokenCommand()); Executions.getCurrent().getDesktop().addListener(new ZoomCommand()); @@ -485,7 +491,9 @@ public class AdempiereWebUI extends Window implements EventListener, IWeb if (appDesktop != null) appDesktop.setClientInfo(clientInfo); - } + } else if (event.getName().equals(ON_LOGIN_COMPLETED)) { + loginCompleted(); + } } @@ -541,10 +549,13 @@ public class AdempiereWebUI extends Window implements EventListener, IWeb if (desktop.isServerPushEnabled()) desktop.enableServerPush(false); Session session = logout0(); - - //clear context and invalidate session + DesktopCache desktopCache = ((SessionCtrl)session).getDesktopCache(); + + //clear context Env.getCtx().clear(); - ((SessionCtrl)session).invalidateNow(); + + //invalidate session + ((SessionCtrl)session).invalidateNow(); //put saved context into new session Map map = new HashMap(); @@ -555,7 +566,12 @@ public class AdempiereWebUI extends Window implements EventListener, IWeb newSession.setAttribute(SAVED_CONTEXT, map); properties.setProperty(SessionContextListener.SERVLET_SESSION_ID, newSession.getId()); - Executions.sendRedirect("index.zul"); + //redirect must happens before removeDesktop below, otherwise you get NPE + Executions.getCurrent().sendRedirect("index.zul"); + + //remove old desktop + if (desktopCache != null) + desktopCache.removeDesktop(desktop); } @Override diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WAttachment.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WAttachment.java index 0c318c0f8a..ad530fc84c 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WAttachment.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WAttachment.java @@ -575,7 +575,6 @@ public class WAttachment extends Window implements EventListener } else if (e.getTarget() == bDeleteAll) { // Delete Attachment deleteAttachment(); - dispose(); } else if (e.getTarget() == bDelete) { // Delete individual entry and Return deleteAttachmentEntry(); @@ -676,6 +675,7 @@ public class WAttachment extends Window implements EventListener m_attachment.delete(true); m_attachment = null; } + dispose(); } } }); diff --git a/org.adempiere.ui.zk/index.zul b/org.adempiere.ui.zk/index.zul index 0b4ea79e85..c3f0a69bf4 100644 --- a/org.adempiere.ui.zk/index.zul +++ b/org.adempiere.ui.zk/index.zul @@ -103,7 +103,7 @@ Copyright (C) 2007 Ashley G Ramdass. } }); - zk.afterLoad('zul.wgt', function () { + zk.afterLoad('zul.inp', function () { // should filter out for only component inside standard window or component wish fire this event, // or ever rise other event like start editting to distinguish with true onChange event