|
Let us follow the long tradition of first saying "Hello World!" when learning a new programming environment. After that, we can go through a more detailed example that implements the model-view-controller architecture. The two examples given are really simple, but this is mostly because Vaadin is designed to make things simple. Example 1.1. HelloWorld.java import com.vaadin.ui.*;
public class HelloWorld extends com.vaadin.Application {
public void init() {
Window main = new Window("Hello window");
setMainWindow(main);
main.addComponent(new Label("Hello World!"));
}
} The first thing to note is that the example application extends Initialization of the application first creates a new window object and sets "Hello window" as its caption. The window is then set as the main window of the application; an application can actually have many windows. This means that when a user launches the application, the contents of the "main window" are shown to the user in the web page. The caption is shown as the title of the (browser) window. A new user interface component of class The following screenshot shows what the "Hello World!" program will look like in a web browser. ![]() Before going into details, we should note that this example source code is complete and does not need any additional declaratively defined template files to be run. To run the program, you can just add it to your web application, as explained in Section 4.8, “Setting Up the Application Environment”. |
Table of Contents
|