Time for action – reading request parameters
Follow these steps and see how easy it is to use request parameters in Vaadin:
Create a new Vaadin project. We are using website2 as project name.
Code your
UI
class shown as follows:public class Website2UI extends UI { protected void init(VaadinRequest request) { final VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); setContent(layout); String page = request.getParameter("page"); if (page == null) { layout.addComponent(new Label("Welcome to Simple Web Site")); getPage().setTitle("Simple Web Site"); } else if ("1".equals(page)) { layout.addComponent( new Label("Oh yeah! You are watching Page 1!")); getPage().setTitle("Simple Web Site - Page 1"); } else if ("2".equals(page)) { layout.addComponent(new Label("Yay! This is Page 2!")); getPage().setTitle("Simple Web Site - Page 2"); } else { getPage().setTitle("Simple Web Site - 404!"); ...