How-tos

With Vaadin Framework, create stunning Web UIs with plain Java

Share this post:

Vaadin Framework is a tool to build good looking Web apps without working with low-level Web technologies. The framework itself contains all the logic to create the modern Web app while you concentrate on the UI itself, using a familiar component based approach, almost like you’re building a traditional desktop app. In this article, we’ll look at two alternatives, along with really trimmed down examples, and a how-to-get-started with Java Web apps in Bluemix from scratch.

Screen shot collage of Vaadin Framework DashboardThe screenshot above is from the Dashboard demo.

Vaadin apps can be run in Bluemix easily, as Vaadin basically just requires a servlet container, like the WebSphere Liberty Profile which is available in Bluemix. We have previously covered using the Vaadin boilerplate application example, which builds on Java EE architecture, uses EJBs and JPA to access a traditional relational database. But not all apps need that kind of “enterprise grade” architecture.

Let’s get started!

Using the Vaadin Maven archetype

Vaadin logoThe first thing you will need to do is register for Bluemix, if you don’t already have an account. There is a 30-day free trial you use for the purposes of this blog article.

All IDE integrations in Vaadin are now based on Maven archetypes, which practically create for you the basic build scripts to create a war file and a simple “hello world” example code. The first step is to create such a project using our getting started instructions. Feel free to use either command line in the Maven or IDE approach.

Once you have the project ready and you have built the war file, you’ll need to push the WAR file to Bluemix. An easy way to do is with the Bluemix/CloudFoundry CLI tools. Unless you have already done it, follow the instructions on how to install and login to your account. Then, after the login, you can just apply the following command from the projects root directory:

cf push your-server-name -p target/*.war

Note that if you are using Windows, replace the star character with the exact name of the generated war file.

If you want to simplify the subsequent push commands to update your app, create a manifest.yml file with the following content:

applications:
– name: your-server-name
path: target/your-war-file-name.war

Then, updating the app simply happens with the “cf push” command.

Starting with start.spring.io

Spring Boot is a new and interesting approach to building Java web applications. With it, you’ll not only create a traditional war file (at least by default), but a jar file which embeds the Web server as well. So instead of feeding Bluemix with a war file, which is then given to a Java Web server, you’ll push that jar file. The “buildpack” in Bluemix is smart enough to handle both war files and jar files.

To create and deploy a Spring Boot-powered Vaadin app to Bluemix, first create a project using start.spring.io, create a simple Vaadin UI and build the jar file. See the beginning of this introduction webinar if you need more help to get started with Spring Boot and Vaadin.

Once you have the project built, the command to deploy and update the app is almost the same as with war packaged web apps:

cf push your-server-name -p target/*.jar

When Bluemix receives the jar file, it automatically figures out it should launch this file using “java -jar your-app.jar” command, instead of creating a Liberty server and deploying the app there. Naturally, you can create a similar manifest file as with war files to simplify the process.

What next?

Now you have the basics set, the rest is just plain Java development. If you want to learn more Vaadin development, the best resource is the Vaadin tutorial. Then just use your Java skills and the huge amount of available Java libraries to implement the application of your dreams.

Sign up for Bluemix and get started with Vaadin apps. It’s free!

More How-tos stories
August 13, 2018

CI/CD Pipeline for OpenWhisk Functions Using Whisk Deploy

The article presents a technique for developing a CI/CD pipeline in IBM Cloud for OpenWhisk functions using Whisk Deploy configuration cataloged in GitHub.

Continue reading

August 8, 2018

Creating A Microservice Data Lake With IBM Cloud Object Storage and IBM SQL Query

Is your application's data a stream trickling into a puddle or a rising tide overwhelming the levees? Either way, IBM has you covered with tools to store, retrieve, query, and gain insights from data of any size.

Continue reading

August 2, 2018

Connecting to IBM Cloud Object Store in Kubernetes

Operationalizing IBM SQL Query: Part 2. In this article, we'll take a look at the best practices for connecting to IBM Cloud Object Storage from docker containers deployed in the IBM Cloud Kubernetes Service.

Continue reading