Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replacement for Application class in Vaadin 7

I guess the Application class has been removed from Vaadin 7 and setMainWindow() no longer works.

public class MyApplication extends Application {   //ERROR coz there's no Application class
    public void init() {
        Window mainWindow = new Window("My Application");
        setMainWindow(mainWindow);          //Error setMainWindow not defined
        mainWindow.getContent().setSizeFull();

        MyComposite myComposite = new MyComposite();
        mainWindow.addComponent(myComposite);
    }
}

While the above code works in Vaadin 6, it doesn't work in Vaadin 7. Does anyone know how to fix this? What class to use instead of Application? Please help

like image 819
MEOW Avatar asked Feb 18 '23 06:02

MEOW


1 Answers

New UI Class

You should extend com.vaadin.ui.UI in Vaadin 7. This class represents the entire content area of a web browser window/tab (or portal viewport) in which a Vaadin app is displayed. Every Vaadin app has one UI instance; additional windows opened each have a UI instance as well.

For more information, take a look at the wiki page, Migrating from Vaadin 6 to Vaadin 7.

The first example in that Guide shows a minimal app in both Vaadin 6 and 7, as copied below.

Vaadin 7

Version 7 apps extend UI class.

import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.*;

@Theme("mytheme")
public class MyApplicationUI extends UI {

    @Override
    protected void init(VaadinRequest request) {
        VerticalLayout view = new VerticalLayout();
        view.addComponent(new Label("Hello Vaadin!"));
        setContent(view);
    }
}

Vaadin 6

Version 6 apps extend Application class.

import com.vaadin.Application;
import com.vaadin.ui.*;

public class V6tm1Application extends Application {
    @Override
    public void init() {
        Window mainWindow = new Window("V6tm1 Application");
        Label label = new Label("Hello Vaadin!");
        mainWindow.addComponent(label);
        setMainWindow(mainWindow);
        setTheme(“mytheme”);
    }

}
like image 67
Henri Kerola Avatar answered Feb 23 '23 15:02

Henri Kerola