JavaOne After Event with some cool talks

The JUG Switzerland has announced an event with some talks of the JavaOne 2015. You can find all information here. I’m happy that 2 of the 5 talks are JavaFX / UI related. If you haven‚Äôt had the change to attend JavaOne and live near Zurich you should visit this event.

Dolphin Platform in 15 minutes @ Nighthacking

Michael and I were interviewed at Devoxx about the Dolphin Platform. In the interview we explain the benefits of the framework and show some code. The video was uploaded some minutes ago and you can find it here:

Dolphin Platform & KumuluzEE: JavaEE Microservices with dynamic and rich frontends

Have you heard of KumuluzEE that is one of the 2015 Java Duke’s Choice Award winners? Well, if you haven’t heard about this cool project you should have a look. KumuluzEE is a JavaEE based framework to create microservices and JavaEE based applications that can start on their own without deploying them to a monster application server. If you know Spring Boot the description is quite easy: KumuluzEE is Spring Boot for the JavaEE framework. In this post I will show how you combine kumuluzEE with Dolphin Platform to create lightweight microservices with a dynamic frontend.

KumuluzEE overview

When using KumuluzEE you can work with all the JavaEE specs that you already know. Let’s say you want to create an application that provides some REST endpoints and uses CDI internally. To do so you need to add the following dependencies to your project:

Let’s have a deeper look what this dependencies define and add to your project:

  • The kumuluzee-core dependencies is the basic dependency of KumuluzEE and must be added to each project
  • The kumuluzee-servlet-jetty dependencies adds an embedded jetty. This includes the implementation of the servlet API. If you only want to code based on servlets you are done now.
  • The kumuluzee-cdi dependencies adds CDI support to you application. Once this dependency is on your class path you can use CDI in your server application.
  • The kumuluzee-jax-rs dependencies adds support for JAX-RS. By adding this dependency you can add REST endpoints to your application

Once this is done you can create your (microservice) JavaEE application. You can use all the defaults of the specs that are added as dependencies. The following code shows how a REST endpoint might look like:

To start your app kumuluzEE adds the class that contains a default main method. By starting the application your endpoints will be up faster than you can spell “weblogic”.

KumuluzEE and Dolphin Platform

Since KumuluzEE supports all the JavaEE specs that are needed for the Dolphin Platform it’s quite easy to create a Dolphin Platform application based on KumuluzEE. To do so you only need to add the following dependencies to your application:

Please notice that the feature is still in development and will be part of Dolphin Platform 0.7.0 ūüėČ

Once this is done you can start to create your Dolphin Controllers that will automatically be managed by JavaEE and support features like CDI.


Thanks to KumuluzEE you can create lightweight Dolphin Platform applications by using the enterprise framework APIs that you might now and like since years. The best: Since you don’t use specific JavaEE or Spring code in your Dolphin Platform controllers they will work in both Spring and JavaEE. Just add the right dependency and your controllers will be automatically managed by the container. In my last tests both implementations bootstrapped in under 7 seconds :)

Building modern web UIs with Web Components University @ Devoxx

On Monday Michael and did a 3 hour university about Web Components and Polymer at Devoxx. Today the Devoxx team announced that all Devoxx talks will be published to YouTube. This are awesome news :)

Next to this the Devoxx team is really fast with the video post production and therefore or talk is already online:

Dolphin Platform has been released

We planed to release the Dolphin Platform before JavaOne but the preparation of the JavaOne Voting Machines took more time then expected and we can’t finish all the todos that we had to fully open source the Dolphin Platform. Since JavaOne is over for more than a week we found some time to finish all the steps and I’m proud to announce the first Dolphin Platform release :)

As a first step we uploaded the Dolphin Platform website and added some descriptions and information about the framework. In addition we created a first tutorial and a “getting started” guide. All the Java sources (client and server) are uploaded to Github, a first release has been created and was uploaded to Maven Central / JCenter.
If you want to try Dolphin Platform you can create your first application by simply adding the following dependencies:

For a Spring Boot based server you only need to add the following dependency:

For a JavaFX based client you need to add the following dependency:

If you are new to Dolphin Platform you can find some post about the API in my blog. In addition we spend some time to create the JavaDoc of the public API. If you have any questions please leave a comment or ask us on twitter. For news about Dolphin Platform you should follow the official twitter account @DolphinPlatform.

Java Script client libraries

As I mentioned before Dolphin Platform supports several client technologies. Next to the JavaFX library we hosted the sources for the basic JavaScript client library and the Polymer client library on github. We will add releases of the libraries this week. Once this is done I will blog how you can simply add Dolphin Platform to your web project by using bower.


Here is an overview of all important links:

Dolphin Platform Web Frontends with Polymer

For the Dolphin Platform release we plan to offer several demos and tutorials as a starting point. Currently I’m working on a simple chat app that contains a JavaFX and a web frontend. The web frontend is done by using Google Polymer and web components. In this post I will give a preview how you can create web applications with¬†the Dolphin Platform by using Polymer.

All the main concepts are already described in the post about JavaFX clients and in this post I will show you that you can reuse all the concepts for a web application.

The following picture shows how the final application will look like:


To create a client that can communicate with the Dolphin Platform server a client context is needed. In an web application this can simply be done by defining a global JavaScript value:

As we use web components when creating an application by using Polymer all view elements of our application are defined as components. In the chat example one chat view is defined as a Polymer based web component. For such a component the minimum code looks like this:

Once this is done you can simply use the component in your web application as a custom tag:

To create a web component that acts as a Dolphin Platform you only need to add one more line of code:

Polymer supports extending custom element prototypes with shared code modules called behaviors. The Dolphin Platform client API provides such a base behavior and therefore you can connect a web component with a Dolphin Platform controller by only adding one line of code. The ThreadViewController is the server side controller for this view. The code of this Java class looks like this:

I don’t want to discuss the Dolphin Platform controller API here and therefore all the methods of the controller are empty at the moment. Here it’s important to know that the controller instance and the view share one model that is defined by the ChatThreadBean class:

As you can see in the code the model contains a chat id, the typed text and a list of all chat messages that should be shown in the chat thread. Let’s have a look how we can use this model on the client.

By adding the Polymer behavior the Dolphin Platform model will automatically be injected in the component context. It is stored in the JavaScript model value. This means that the following JavaScript call will show a dialog that contains the current typed text:

In addition Polymer defines a binding API this is automatically used by the model. Thanks to this you can simply bind your model or parts of your model to HTML attributes in the web component template by using the mustache syntax. here you see how the typed text is bound to the input field in the chat view:

Easy, isn’t it?

Thanks to the modularity of web components you can even go deeper and use your model in sub components. In the chat example each message in the chat is defined by a web component. To do so we created the custom component chat-message that defines how one chat message should be visualized. Now we can define the complete chat by only 3 lines of HTML code:

The don-repeat elect is a special Polymer elect that add it’s content for each item in a given list. As we said earlier all the chat messages in our model are defined as a list. This list can easily be accessed by calling model.messages.

If you already read the post about JavaFX clients you might notice all the parallels. By using the Dolphin Platform API it’s really easy to create interactive and modern clients for several platforms without loosing the control of the UI.

A short preview of the JavaOne Voting Machine

Today I want to give a short preview of the JavaOne Voting Machine that is build for this year JavaOne as a cooperative project by Canoo and Oracle.


Voting Machine devices will be placed in every room at JavaOne. By doing so attendees can directly vote for each session and the voting results will be shown on a central leaderboard.


Currently Michael Heinrichs and I manufacture and test all the devices in Silicon Valley and hope to have all of them finished with the beginning of the next week :)


JavaFX 8 RefCard

Together with Michael Heinrichs and DZone I created a JavaFX 8 RefCard.


The RefCard gives an overview of the most important JavaFX APIs like CSS, Properties or Controls. Here are some snippets of the card:



If you want to learn JavaFX or just need a quick overview while coding this refCard is the perfect choose for you :)

You can download the RefCard as a PDF at DZone for free or order some printed copies.

JavaOne Preview

This year I will give 2 talks at JavaOne. For a short preview of the talks we recorded some videos in that I give a short overview about its topics.
The first talk will be “JavaFX Enterprise 2.0” that is a successor of my last year “JavaFX Enterprise” talk. I will do the talk together with Alexander Casall. Here is the video:

The second talk will be about the JavaOne Voting Machine. For JavaOne we (Canoo) created a JavaFX based embedded device to vote all the JavaOne sessions that you will attend directly after the talk.
If you will attend JavaOne you will find Voting Machines in every room. If you can’t attend the conference I will write a post about the technology and the UI later. I will do the talk together with Gerrit Grunwald and Michael Heinrichs. Here is the video:

Between the talks I would love to talk with you about the Dolphin Platform :)

In addition I will use this post to promote another talk about Functional Reactive Programing with UI toolkits by Michael Heinrichs. We created a short video for this talk, too.

Dolphin Platform: How to create an application

In this post I will show a first end to end example of the Dolphin Platform. In my last posts I already gave an overview about the concepts and APIs of the Dolphin Platform. If you have missed this post you can find them here.

The calculator application

The application that I will create in this post might not be the coolest one but I think that it gives a good overview of the Dolphin Platform concepts and APIs. The final application should calculate the sum of to values and look like it is shown in the following picture:
A user can type in 2 values in the textfields on the left and the result textfield will automatically be updated. In addition I will add a “reset” button that resets the content of the textfields. In general the complete functionality can be described like it is sketched in this picture:
As the complete controller logic will be defined on the server when using Dolphin Platform the addition of the values and the reset action will be defined in server side controller. This might be very useful for this small example but think about bigger applications with complex calculation or a persistence layer. In addition you don’t need to code the logic several times if you want to support desktop, mobile and web clients.
Before we start to create the application by using the Dolphin Platform I will create a client only application by using JavaFX. That’s why I decided to use an example that normally don’t need a server. We can create a client side only application by using only JavaFX. By doing so we can compare the 2 solutions later and the Dolphin Platform integration for JavaFX might become more clear. So this post might not show all benefits of the Dolphin Platform but will give a good overview of its basic APIs.

The JavaFX calculator application

As a first step I will create the layout of the application by using the SceneBuilder that can be downloaded at Gluon. Here is a picture of my final layout in SceneBuilder:
Once this is is saved as a view.fxml file we can use it in JavaFX. Here is the content of the fxml file:

As a next step we need a controller class that add some interaction and bindings to our view. In JavaFX you can create a view by bundling a controller class and a fxml file. By doing so you can inject controls that are defined in the fxml description directly in your Java controller.
Let’s start with a controller that injects all controls that we need for our use case:

In this class I already add a initialize() method that will automatically be called by JavaFX after all controls has been injected in the controller instance. Sadly this is done by some kind of magic and JavaFX don’t provide an default interface for this behavior. You need to know that you can add this method to your controller class by reading the FXML documentation.
For this small example we don’t need to add any other methods to the controller. Everything we want to do can be defined in the init method. Here we need to add an action to the reset button and define an binding for the values to automatically update the result value. I don’t want to describe the JavaFX API in deep and just show the final source code of the method:

As a last step we need to create or view and show it on screen. Here is the main application class that does everything that we need:

Once this is done we can start our application and it’s working as expected:

The Dolphin Platform based calculator application

When creating an application based on the Dolphin Platform I start to define the model and code the basic controller functionality. Let’s start with the model definition (A first description of the Dolphin Platform model API ca be found here). In the given example the model is quite small and a matching Dolphin Platform model will look like this:

If you want to simply use getter and setter methods when working with the model you can add some convenience methods:

The model class should be defined in a module that is shared between the client and server sources.

Once the model is done we can start working on the controller. As described in the first overview a controller will be managed by the web container on server side. Based on this all the well known Spring and JavaEE specifications can be used in Dolphin Platform controllers. In this example we will make use of the @PostContruct annotation that marks our init() method. This method will automatically be called once the controller has been created. In the init() method we can add some listeners to our model since the model instance is already created and injected in the controller instance when the @PostContruct is handled.

Once this is done we need to add some additional features to the controller class. Let’s start with the calculation. Here we can reuse most of the code that we already used in the JavaFX only example since the Dolphin Platform Property definition is similar to the JavaFX one:

The last think that is missing is the “reset” functionality. Here we create a Dolphin Action that can be triggered by a client. To do so the @DolphinAction annotation can be used. Once we created the action our controller is done and will look like this:

Now we are mostly done with the server side of our example. Since we want to use Spring Boot to run the server we need to add a main class to our application. Dolphin Platform adds Spring Boot support and therefore such a class is quite small:

Spring Boot will automatically find the Dolphin controller and create a new instance whenever a client creates a matching view.

For the JavaFX client we will create an application class that extends the javafx.application.Application as any other JavaFX application. Here we directly create the connection to our Dolphin Platform based server application that is defined by the ClientContext class:

For the view we will use the same MVC and FXML based approach as in the first JavaFx example. Here we can reuse the FXML file (“view.fxml”) since the UI won’t change. But by using Dolphin Platform the controller will be much smaller. Since the real controller class is already defined on the server we only need to define some bindings here. To do so we can extend the Dolphin Platform class AbstractViewBinder that defines all information that we need to create an interactive UI. Here we will inject all UI elements by using the @FXML annotation like before. The AbstractViewBinder class defines the abstract init() method that we need to implement in our class:

I will define the content of the init() method later and finish the application class first. Here we can now load the FXML with the given controller and show it on screen:

As you can see we only use well known JavaFX APIs here. Once this is done you can already start the server and client applications. But you won’t see any data on the client since the binding is still missing. To create a binding in JavaFX the Dolphin Platform offers a helper class called FXBinder. By using the class you can define (bidirectional) bindings between Dolphin Platform properties and JavaFX properties:

As a last step we need to define the rest function. To do so we can add an action handler to the button. In the handler we will trigger the Dolphin Action on server side. Here is the code of the final view binder class:

Now we can use the client and the calculation and reset will be done on the server :). Well, this might not be necessary for the given small example but for more complex applications this handling is awesome. There are several benefits:

  • If you are using a web client the user can’t see any business source code since it’s completely on the server side
  • In bigger Dolphin Platform based application the client layer is so small that you can easily change it or add an additional client type. By doing so you can easily create an application that is running in the browser and as a desktop application
  • As we will see in a future post the interaction between several clients can easily be created by using Dolphin Platform because the model and the controller for all client instances life on the server side
  • There are several addition benefits like security, authorization, or persistence.

I will blog in more detail about all these benefits in future posts

I think you will see the benefit when thinking about an additional feature. Let’s say the data of the application should be stored in a database whenever an calculation has been done. When doing this with JavaFX we need to connect to a database, handle transactions in the client and do a lot of more stuff. Server frameworks already contain all those features and since the Dolphin Platform example is based on Spring Boot we can simply use Spring Data here. In this case we only need to inject a Spring Data repository in our controller class and simply store the calculation in the DB. All challenges like transaction support will be handled by Spring in this case. When doing so your controller might look like this:

This was the first complete “getting started” example of the Dolphin Platform and I hope that you like the basic concepts. We plan to upload the Dolphin Platform sources to GitHub in the next days and deploy a first preview release to Maven Central before JavaOne.
In addition I plan to add a post about Polymer based clients and how you can create web clients by using the Dolphin Platform. Stay tuned ūüėČ