changeset 4215:c179cd02177d

Logout the current user Add code to the logout button to remove the current user from the session and to redirect the browser window to the login page. Part of flys/issue916 (Logout: "Abmelden" Knopf mit Funktion belegen)
author Björn Ricks <bjoern.ricks@intevation.de>
date Tue, 23 Oct 2012 09:59:16 +0200
parents e39ac9767a69
children a04862abce42
files flys-client/src/main/java/de/intevation/flys/client/client/ui/MainMenu.java
diffstat 1 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/MainMenu.java	Tue Oct 23 09:57:42 2012 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/MainMenu.java	Tue Oct 23 09:59:16 2012 +0200
@@ -3,6 +3,7 @@
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.i18n.client.LocaleInfo;
 import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.rpc.AsyncCallback;
 import com.smartgwt.client.types.Alignment;
 import com.smartgwt.client.util.BooleanCallback;
 import com.smartgwt.client.util.SC;
@@ -14,6 +15,8 @@
 
 import de.intevation.flys.client.client.FLYS;
 import de.intevation.flys.client.client.FLYSConstants;
+import de.intevation.flys.client.client.services.UserService;
+import de.intevation.flys.client.client.services.UserServiceAsync;
 import de.intevation.flys.client.shared.model.User;
 
 
@@ -49,6 +52,9 @@
     /** The button to open an info panel.*/
     protected Button info;
 
+    protected UserServiceAsync userService =
+        GWT.create(UserService.class);
+
     /**
      * The default constructor for creating a new MainMenu.
      */
@@ -88,7 +94,15 @@
             @Override
             public void onClick(ClickEvent event) {
                 GWT.log("Clicked 'logout' button.");
-                GWT.log("IMPLEMENT the 'logout' function.");
+                userService.logoutCurrentUser(new AsyncCallback<Void>() {
+                    public void onFailure(Throwable caught) {
+                    }
+
+                    public void onSuccess(Void result) {
+                        Window.Location.replace("/login.jsp");
+                    }
+                });
+
             }
         });
 

http://dive4elements.wald.intevation.org