Time for action – developing a simple website
Let's see how we can do this using Vaadin.
Start up your IDE and create a new Vaadin project. We are using website as project name.
Code your
UI
class as shown in the following code snippet:public class WebsiteUI extends UI { protected void init(VaadinRequest request) { final VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); setContent(layout); String page = request.getPathInfo(); if (page == null || page.isEmpty() || "/".equals(page)) { layout.addComponent(new Label("Welcome to Simple Web Site")); getPage().setTitle("Simple Web Site"); } else if ("/page1".equals(page)) { layout.addComponent( new Label("Oh yeah! You are watching Page 1!")); getPage().setTitle("Simple Web Site – Page 1"); } else if ("/page2".equals(page)) { layout.addComponent(new Label("Yay! This is Page 2!")); getPage().setTitle("Simple Web Site – Page 2"); } else { ...