# HG changeset patch # User Björn Ricks # Date 1350979156 -7200 # Node ID c179cd02177d78eeb4f48f2b078469b876ad4d6a # Parent e39ac9767a69a26f63a24e7bd6a22b99c0127523 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) diff -r e39ac9767a69 -r c179cd02177d flys-client/src/main/java/de/intevation/flys/client/client/ui/MainMenu.java --- 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() { + public void onFailure(Throwable caught) { + } + + public void onSuccess(Void result) { + Window.Location.replace("/login.jsp"); + } + }); + } });