Naming the tab/application name in Vaadin 7

Hi all,

I am very new to Vaadin, but I liked the tab capabilities of Vaadin 7. One thing that I am a little stumbled with is that I can’t figure out how to change the name of my application as it is displayed in the tab for the browser. Currently it reads “Vaadin 7”.

In the previous release so long as I created a main window it would set the name of the tab as such:

Window mainWindow = new Window("My Application Name");

With this new Root context I can’t quite find where the setter is.

Thanks,

You just need call setCaption at init.

public void init(WrappedRequest request) {
	setCaption("title");

Please note that although this is currently the “official” way of setting the browser window title, there might still come changes to this in upcoming alpha releases.

The reason for this is that setting the browser window title based on the caption of the Vaadin root is semantically wrong e.g. in situations where there are multiple roots on the same page.


Root.setCaption
is now deprecated (at list in alpha3) and you get an IllegalStateException when trying to use it

java.lang.IllegalStateException: You can not set the title of a Root. To set the title of the HTML page, use Page.setTitle
        at com.vaadin.ui.Root.setCaption(Root.java:1069)

You have to use

Page.getCurrent().setTitle(xxx)

just use getPage().setTitle(“name”);