Time for action – developing a simple website

Let's see how we can do this using Vaadin.

  1. Start up your IDE and create a new Vaadin project. We are using website as project name.
  2. 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 ...

Get Vaadin 7 UI Design By Example Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.