Starting with a new technology is often hard. Even if the technology is documented and follows the pattern and structures that you already know from other APIs or frameworks the initial start is always a problem. To simplify this start when working with the Dolphin Platform, we created a first Maven archetype that creates a simple client server application.
This application is an ideal starting point to play with the Dolphin Platform framework, learn the APIs or directly start your own application based on Dolphin Platform.
The Maven multi module project that is created by using this first archetype contains a Spring Boot based server and a JavaFX client. With this archetype you can create your own project directly in an IDE like IntelliJ or by using the shell. If you want to use the shell you need maven on your system. IDEs like IntelliJ contain a bundled Maven instance and you don’t need to install anything on your system (without the IDE).
The following video shows how you can create your first Dolphin Platform application in 1 minute by using IntelliJ:
We will post about other IDE and the commandline usage later.
If you have any questions about Dolphin Platform you can now use the “dolphin-platform” tag at stackoverflow. If you are new to Dolphin Platform you can find general information and tutorials on the Dolphin Platform website.
In modern UI’s you can often find round avatar images like shown in this image:
Creating these special UI nodes with JavaFX isn’t that hard. The most important JavaFX features to create such a rounded image is clipping. By using clipping you can define the area in that a control can draw it’s content. A clip can be any shape and you only need to set the shape property of a JavaFX Node instance to define its clipping. You can find an additional clipping description here.
Let’s start creating the component. As a first step we will define a Circle shape as a clip and define it for an ImageView instance:
In addition a border should be added to the component. To do so we add one (or several) Circle shapes on top of the ImageView:
In the JavaFX code you can simply bind the bounds of the image to the bounds of the clip and the circle instances that are used as a border.
Michael Heinrichs and Hendrik Ebbers were interviewed at Devoxx about the Dolphin Platform. In this interview they explain the benefits of the framework and show some code:
For the Dolphin Platform release we plan to offer several demos and tutorials as a starting point. Currently, we are 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 blog post, we will give a preview on how to create web applications with the Dolphin Platform by using Polymer.
All the main concepts are already described in the post about JavaFX clients. In this post, we 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:
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:
We don’t want to discuss the Dolphin Platform controller API here and therefore all the methods of the controller are empty at the moment. 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.
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 dom-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.