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
UI
ClassYou 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.
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);
}
}
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”);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With