comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/MainMenu.java @ 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 725470fc57d2
children a04862abce42
comparison
equal deleted inserted replaced
4214:e39ac9767a69 4215:c179cd02177d
1 package de.intevation.flys.client.client.ui; 1 package de.intevation.flys.client.client.ui;
2 2
3 import com.google.gwt.core.client.GWT; 3 import com.google.gwt.core.client.GWT;
4 import com.google.gwt.i18n.client.LocaleInfo; 4 import com.google.gwt.i18n.client.LocaleInfo;
5 import com.google.gwt.user.client.Window; 5 import com.google.gwt.user.client.Window;
6 import com.google.gwt.user.client.rpc.AsyncCallback;
6 import com.smartgwt.client.types.Alignment; 7 import com.smartgwt.client.types.Alignment;
7 import com.smartgwt.client.util.BooleanCallback; 8 import com.smartgwt.client.util.BooleanCallback;
8 import com.smartgwt.client.util.SC; 9 import com.smartgwt.client.util.SC;
9 import com.smartgwt.client.widgets.Button; 10 import com.smartgwt.client.widgets.Button;
10 import com.smartgwt.client.widgets.Label; 11 import com.smartgwt.client.widgets.Label;
12 import com.smartgwt.client.widgets.events.ClickHandler; 13 import com.smartgwt.client.widgets.events.ClickHandler;
13 import com.smartgwt.client.widgets.layout.HLayout; 14 import com.smartgwt.client.widgets.layout.HLayout;
14 15
15 import de.intevation.flys.client.client.FLYS; 16 import de.intevation.flys.client.client.FLYS;
16 import de.intevation.flys.client.client.FLYSConstants; 17 import de.intevation.flys.client.client.FLYSConstants;
18 import de.intevation.flys.client.client.services.UserService;
19 import de.intevation.flys.client.client.services.UserServiceAsync;
17 import de.intevation.flys.client.shared.model.User; 20 import de.intevation.flys.client.shared.model.User;
18 21
19 22
20 /** 23 /**
21 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> 24 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
46 /** The button to switch between the english and german version.*/ 49 /** The button to switch between the english and german version.*/
47 protected Button language; 50 protected Button language;
48 51
49 /** The button to open an info panel.*/ 52 /** The button to open an info panel.*/
50 protected Button info; 53 protected Button info;
54
55 protected UserServiceAsync userService =
56 GWT.create(UserService.class);
51 57
52 /** 58 /**
53 * The default constructor for creating a new MainMenu. 59 * The default constructor for creating a new MainMenu.
54 */ 60 */
55 public MainMenu(FLYS flys) { 61 public MainMenu(FLYS flys) {
86 92
87 logout.addClickHandler(new ClickHandler() { 93 logout.addClickHandler(new ClickHandler() {
88 @Override 94 @Override
89 public void onClick(ClickEvent event) { 95 public void onClick(ClickEvent event) {
90 GWT.log("Clicked 'logout' button."); 96 GWT.log("Clicked 'logout' button.");
91 GWT.log("IMPLEMENT the 'logout' function."); 97 userService.logoutCurrentUser(new AsyncCallback<Void>() {
98 public void onFailure(Throwable caught) {
99 }
100
101 public void onSuccess(Void result) {
102 Window.Location.replace("/login.jsp");
103 }
104 });
105
92 } 106 }
93 }); 107 });
94 108
95 language.addClickHandler(new ClickHandler() { 109 language.addClickHandler(new ClickHandler() {
96 @Override 110 @Override

http://dive4elements.wald.intevation.org