diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/SessionContextCallback.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/SessionContextCallback.java index 31d18c42b03e9b7c892b04a47c49a10da9d44550..feebd79f7b256506481e472ef70f1dea6b14d952 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/SessionContextCallback.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/SessionContextCallback.java @@ -20,6 +20,7 @@ import com.extjs.gxt.ui.client.mvc.Dispatcher; import ch.systemsx.cisd.openbis.generic.client.web.client.ICommonClientService; import ch.systemsx.cisd.openbis.generic.client.web.client.application.framework.AppEvents; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.GWTUtils; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IDelegatedAction; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.SessionContext; @@ -60,6 +61,7 @@ public final class SessionContextCallback extends AbstractAsyncCallback<SessionC viewContext.getModel().setSessionContext(sessionContext); dispatcher.dispatch(AppEvents.INIT); afterInitAction.execute(); + GWTUtils.setAllowConfirmOnExit(true); } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/menu/user/action/LogoutAction.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/menu/user/action/LogoutAction.java index b6cba07e4af271b2e19087174b97464130ebdebd..78c7e3e5dd604260ca172f3fe6fd009e0e863748 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/menu/user/action/LogoutAction.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/menu/user/action/LogoutAction.java @@ -19,6 +19,7 @@ package ch.systemsx.cisd.openbis.generic.client.web.client.application.menu.user import ch.systemsx.cisd.openbis.generic.client.web.client.ICommonClientServiceAsync; import ch.systemsx.cisd.openbis.generic.client.web.client.application.AbstractAsyncCallback; import ch.systemsx.cisd.openbis.generic.client.web.client.application.IViewContext; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.GWTUtils; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IDelegatedAction; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DisplaySettings; @@ -54,6 +55,7 @@ public class LogoutAction implements IDelegatedAction public final void process(final Void result) { viewContext.getPageController().reload(true); + GWTUtils.setAllowConfirmOnExit(false); } } } \ No newline at end of file diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/util/GWTUtils.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/util/GWTUtils.java index 6c6c1cdbd99ef4a693554f37a7e3d2e2172421e1..56d55eeb350e61a8ee6e2bb243e6a159307a157c 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/util/GWTUtils.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/util/GWTUtils.java @@ -231,21 +231,35 @@ public final class GWTUtils return (O) (selectedModel != null ? selectedModel.get(ModelDataPropertyNames.OBJECT) : null); } + /** Returns base URL to the index page of the application. */ + public final static String getBaseIndexURL() + { + return GWT.getModuleBaseURL() + "index.html"; + } + + // + // native JavaScript + // + /** * Returns the <i>search</i> of a <i>Javascript</i> window location (without the starting * <code>?</code> if any). * * @return something like <code>key1=value1&key2=value2</code>. */ - public final static native String getParamString() /*-{ - var search = $wnd.location.search; - return search.indexOf("?") == 0 ? search.substring(1) : search; - }-*/; + public final static native String getParamString() + /*-{ + var search = $wnd.location.search; + return search.indexOf("?") == 0 ? search.substring(1) : search; + }-*/; - /** Returns base URL to the index page of the application. */ - public final static String getBaseIndexURL() - { - return GWT.getModuleBaseURL() + "index.html"; - } + /** + * Depending on specified <var>allowConfirmOnExit</var> when user tries to exit application + * confirmation dialog will or will not appear. + */ + public final static native void setAllowConfirmOnExit(boolean allowConfirmOnExit) + /*-{ + $wnd.setAllowConfirmOnExit(allowConfirmOnExit); + }-*/; } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/index.html b/openbis/source/java/ch/systemsx/cisd/openbis/public/index.html index 5d463b18703e8589d64f4af59d2769223de1f517..736a085ba3e795a84cb8561e1bd4ea01a545de0a 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/public/index.html +++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/index.html @@ -8,11 +8,19 @@ --> <script language="javascript" src="ch.systemsx.cisd.openbis.OpenBIS.nocache.js"></script> <script language="JavaScript"> + // confirmation on exit depends on whether user is logged in + var allowConfirmOnExit = false; window.onbeforeunload = confirmExit; function confirmExit() { - return "WARNING: By doing this you will in fact leave openBIS!" + if (allowConfirmOnExit) { + return "WARNING: By doing this you will in fact leave openBIS!"; + } } + function setAllowConfirmOnExit(value) + { + allowConfirmOnExit = value; + } </script> <link rel="shortcut icon" href="images/favicon.ico" /> <link rel="icon" type="image/png" href="images/favicon.png" />