Problem loading Themes handling input Parameters

Hi everybody,
I’m trying to handle input parameters on a Vaadin webapp for authentication purpose, when the app receives username/password as parameters it should display directly the main window if authentication succeeded without showing the login window. This works very good, but the customized theme “myTheme” is never loaded. The only way for loading the theme was setting the user with setUser(user) outside the handleParameters() method.

I hope you can help me. Thanks :slight_smile:


public class GestOrdApplication extends Application implements ParameterHandler, UserChangeListener {

	private static final long serialVersionUID = 1L;

	private Window mainWindow;	
	private Window loginWindow;
	private String user;
	private String password;

	@Override
	public void init() {
		setTheme("myTheme");

		// login
		buildLoginWindow();
		setMainWindow(loginWindow);
		
		addListener(this);
	}
	
	@Override
	public void handleParameters(Map<String, String[]> parameters) {
	
		if (parameters.containsKey("user") && parameters.containsKey("password")) {
			// set user
			user = parameters.get("user")[0]
;
			password = parameters.get("password")[0]
;
			if(auth(user,password)) {
				setUser(user);
			}
		}
	}
	
	@Override
	public void applicationUserChanged(UserChangeEvent event) {
		if (event.getNewUser() == null) {
			// show login
			setMainWindow(loginWindow);
			removeWindow(mainWindow);
			
			loginWindow.showNotification("Logged out.");
		} else if (event.getNewUser() != null) {
			// load UI
			buildMainWindow(user);
			setMainWindow(mainWindow);
			removeWindow(loginWindow);
			
			mainWindow.showNotification("Welcome.");
		}
	}
	
	public void buildMainWindow(String utente) {
		mainWindow = new Window("Main Window");
		mainWindow.setContent(new MainUI());
	}
	
	public void buildLoginWindow(String utente) {
		loginWindow = new Window("Login Window");
		loginWindow.setContent(new LoginUI());
		// startup parameters
		loginWindow.addParameterHandler(this);
	}
}

The setTheme(“myTheme”) method seems to have no effect when I pass parameters to the web application, it’s loaded with the default theme…

Please help me!

Have you tried cleaning the cache of your webserver and the cache of your browser?

Does the trick for me.

Thanks for your answer Robby.

I tried cleaning the browser cache, and it solved other problems on other projects :slight_smile: but not for this… You said to clean the webserver cache… how? I’m using Tomcat and Jetty

In Eclipse when developing I use the view Servers.

Here you should see tomcat. Right click on tomcat shows me 2 clean options.

Else you could clean the working directory (/webapps/) of your tomcat by removing the webapp and redeploy your latest war-file.

I tried with cleaning but nothing… even if I export the web application as a war and I install it on Tomcat after rebooting it…

It seems that the setTheme() method has no effect even if it’s executed :frowning:

I tried adding also mainWindow.setTheme(“myTheme”), but with no success…

Try to replace the contents of the main window (with setContent()) instead of replacing the main window itself.
I am not sure but I think that might help - replacing the main window sometimes causes some problems, and especially here the order of operations might be such that it is the culprit.

Thank you very much Henri! This solved my problem :slight_smile: