Multiple Windows opened error dependent on log

Hi people!

I’m developing a web application with a login service (I’m using Spring too).
In one tab, I’ve a Table that contains an Indexed Container. And if I click a row it opens a new Window (with few options).
So, my problem is that if I log out and I log in again (with same or different User, it doesn’t matter) when I click a row appears a new Window for each log in… eg

loggin A
1 window
loggout A

loggin B
2 windows
loggout B

loggin A
3 windows
loggout A

I don’t know why is happening this… what I’m doing wrong?

Here is my code to log out…
[color=#969696]
@Override
public void buttonClick(ClickEvent event) {
Button source = event.getButton();

if (source == logout) {
app.getMainWindow().getApplication().close();
}
}

[/color]

Any idea??

Hello,
Can you please also post your login code? specifically the part in the button click if the user passes the authentication.

Have you overriden the getWindow method of your Application object ?

Ei!
Here is loggin code too:

[color=#969696]
login.addListener(new Button.ClickListener() {
public void buttonClick(Button.ClickEvent event) {
try {

				// Athenticate the user
                                    // username & password are texfields
				authenticate((String) username.getValue(),
						(String) password.getValue());

				// Switch to the main view
				app.getViewManager().switchScreen(MainView.class.getName(),
						new MainView(app));

			} catch (Exception e) {
				getWindow().showNotification(e.toString());
			}
		}
	});

[/color]

[color=#969696]
public void authenticate(String username, String password) throws Exception {

	if (app.getAuthenticationService() == null) {
		throw new Exception(app.getMessage(Messages.ServiceUnavilable));
	} else if (!app.getAuthenticationService().authenticate(username, password)) {
		throw new Exception(app.getMessage(Messages.FailedLogin));
	} else {

		// Login successful, add user id to session
		app.setUser(username);

	}
}

[/color]

AuthenticationService is a lib offered by other framework (Activiti).
Where should be the override annotation? On class constructor (I haven’t it)?? like…

[color=#969696]

@Override
public LoginView( ) {
[/color]

Keep in touch :smiley: !

Hi,
Well what is it you do in the following methods?


app.getViewManager().switchScreen(MainView.class.getName(),
new MainView(app));

What class is “app” object and “MainView”. It likely that in the switchScreen you do something with the mainwindow of the vaadin application etc . You need to debug that part or keep posting code… i might get somewhere :slight_smile:

p.s. the Override annotation is for compile time and you can place it on whatever you actually override, if you place it wrong you’ll know it since you’ll get an error at compile time.

First, app is AdminApp who starts everything and then it offers to the other classes (is like a main)

[color=#969696]
@Override
public void init() {

	// Set theme
	setTheme(Consts.THEME);

	// Set default locale
	setLocale(new Locale("en"));

	// Init resource bundle
	final ResourceBundle i18n = ResourceBundle.getBundle(
			Messages.class.getName(), getLocale());

	// Add title
	mainWindow = new Window(i18n.getString(Messages.AppTitle));
	
	// Set window to full size
	mainWindow.setSizeFull();

	// Set as main window
	setMainWindow(mainWindow);

	// Add window to view manager
	viewManager = new ViewManager(mainWindow);

	// Create the login screen
	viewManager
			.switchScreen(LoginView.class.getName(), new LoginView(this));

}

[/color]
And in the class ViewManager I have:
[color=#969696]

public void switchScreen(String viewName, Layout newView) {
	Layout view;
	if (newView != null) {
		view = newView;
		views.put(viewName, newView);
	} else
		view = views.get("viewname");
	window.setContent(view);
}

[/color]

I tried to override it but is not allowed (I thought that I undestand how to use override annotation but … maybe I’m wrong :S ).

If could help anybody, my loggin code is based on P.Holmström application. But I changed a lot the UI and few other things…
Here I link you (it’s a really great job):


http://www.dzone.com/links/building_vaadin_uis_for_activitibased_bpm_applica.html

Any idea?
I’m a little bit lost