Priocept have recently been using Vaadin to build the UI on a number of projects. Vaadin is a free and open source platform that has been specifically designed for business applications. These are predominantly back office systems that are web-based, but are usually not publically accessible. The wide range of components available in the framework are well suited for building analytics dashboards, tools managing large product lists, and other similar web-based management tools.
The key benefits to this approach are:
- Less time spent developing user interface components
- Smoother integration between the user interface and business logic
- Rich-client style communication between the client (web browser) and server is handled automatically
- No need for dedicated client-side developers to be added to the team
- Best-practice, intuitive and attractive web interfaces are generated by default using a component based approach, without onerous crafting of HTML layout and CSS styles
- Reduced points of exposure to security vulnerabilities
- Cross-browser compatibility testing and “hacks” are not required as Vaadin is responsible for all browser compatibility implementations
Vaadin 8 and Vaadin 10 offer two different options for the development of a new project. Vaadin 8 currently has a wider array of features on offer and the benefit of a proven and stable codebase. Vaadin 8 will be supported until at least February 2022, so users should be aware of a future requirement for migration to Vaadin 10.
Vaadin also offers further tools such as Vaadin Designer, which can be used to quickly build a new UI and Vaadin TestBench, which automates regression testing. The use of these extra tools does require a subscription, but their use may be justified depending on the scope of your project.
Vaadin builds on the Google Web Toolkit (GWT) to generate client-side code on the server. Vaadin does not require any browser plugins such as Flash. Communication between the client-side browser and the server is achieved via AJAX, but this is entirely abstracted behind Vaadin’s Java API, such as the developer does not need to concern themselves with the details of asynchronous client-server communications.
For web applications, Vaadin enables a developer to quickly prototype a solution including a back-end server without having to be concerned with front-end technologies. This is particularly useful if your development team is more closely aligned to Java development.
Of course there are many cases when we may not recommend Vaadin as part of a solution. For example, it would be wise to look at alternative software architectures if you require explicit control over client-server communication, unlimited control over the visual design of components, or are tied to an existing back-end solution. Similarly, if your requirement is for a website with relatively less server-side functionality, such as brochure website or the launch of an advertising campaign, then Vaadin may not be relevant.
Building the User Interface
The power of Vaadin is in defining the UI in Java code, using higher-level concepts that entirely isolate the developer from HTML or CSS concepts. This can be achieved using a set of layouts to structure your application pages and by adding components to these layouts which include buttons, dropdowns, panels, grids, etc. These can be customized as required, but the defaults include all the necessary components required to build modern web applications. Vaadin includes a default SASS theme providing a clean out-of-the-box look and feel. The choice of whether to customise the default theme or to create a new theme from scratch is left open to the developer.
The use of Vaadin is best illustrated with a quick example. Below we show three buttons defined in Java and a notification displayed when one of the buttons is clicked:
// Create a new button Button button1 = new Button("Normal"); // Create a button with the enabled attribute set to false Button button2 = new Button("Disabled"); button2.setEnabled(false); // Create a button with the primary style (included with Vaadin) Button button3 = new Button("Primary"); button.addStyleName(“primary”); // Create a layout and add the buttons to this VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.addComponents(button1,button2,button3); setContent(verticalLayout);
// Display a notification when button1 is clicked button1.addClickListener(clickEvent -> Notification.show("Button clicked"));
This example shows the simplicity and power of the Vaadin framework. With just a few lines of Java code developers are able to build a fully working UI for their application that is functionally robust, well presented, and cross-browser compatible.
Vaadin is a great choice for building modern web applications that users are expected to interact with dynamically.