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.
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
Here is an overview of all important links:
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
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
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.
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:
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
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 😉
The last days I blogged about the different APIs of the Dolphin Platform. The Dolphin Platform is a new Open Source Framework by Canoo that will be released the next weeks. But one part is still missing: the view. Therefore I will show how you can create JavaFX based clients by using the Dolphin Platform. As already mentioned the Dolphin Platform will provide support for several client platforms like JavaFX, AngularJS or Polymer.
In this post I will focus on the JavaFX support. Other client libraries and APIs will be described in future posts.
The View API
Last but not least I will show how a view will be coded based on the Dolphin Platform. Here the client specific APIs differs in some points because we want to support the core concepts of the underlying UI toolkit. One of the most important points is that a developer can use the concepts he already knows and therefore we decided to not provide the exact same API for all client types. But when having a deeper look at the Dolphin Platform client libraries you will see that the core and low level APIs are the same on all platforms. In this first overview I will give a short sample how a view can be coded in JavaFX.
When creating a JavaFX client you will normally use FXML to create your view. Next to the FXML file you will have a view controller to bind all the properties of the view and attach action handlers.
When talking about the dolphin Platform this view controller is the perfect point to bind the view to the synchronized model and the server side controller. Therefore we call this class the “Binder”. There are several ways how you can define such a binding but the most easy one is to use extend the AbstractBinder class that is part of the Dolphin Platform JavaFX library. This class already implements the complete lifecycle of the view and you can simply bind the synchronized presentation model to your view properties. Here is a small example for a view that contains only one textfield and a button:
Once the view binder is instantiated the server controller and the model will automatically be created on the server. Since the model will be synchronized all the time between client and server you don’t need to create it on the client. After this initialization is done the
onInit() method of the binder will called. Here we bind the the
name property that is part of the synchronized model to the text property of the textfield. In addition we define an action handler for the button. When the button is pressed a action in the server side controller should be called. Top do so the abstract binder provides the
invoke(String name) method that triggers actions on the server controller. In this specific case the server controller might look like this:
As you can see we never send any data to the server. Since the model will be automatically synchronized we can directly store the name string in the model to the database. The Dolphin Platform guarantee that the model will be the same as it’s on the client when pressing the button.
Another nice benefit that you might notice is that even if we have communication between the server and the client we don’t need to handle several threads. The Dolphin Platform handles all the concurrency and handles all actions in the right thread. By doing so the binding between JavaFX properties and Dolphin properties will automatically be handled on the JavaFX application thread.
I hope this post gives a first overview how a client can be created. As already said the Dolphin Platform will provide support for several client platforms like JavaFX, AngularJS or Polymer. I will blog about the specific client APIs in future posts.
Before I will talk the first time about the Dolphin Platform today at “Java Forum Nord” I will use the time to post the next preview. Today I will give a short overview about the model API of the Dolphin Platform. The last days I already gave a general overview and described how the controller API of Dolphin Platform is working.
The Model API
In this view we have several elements that need a data model. If the data of this app is stored on a server the data model must be shared between the client and the server. When having a look at the screen we can see 3 different elements that need data from the data model to visualize itself or provide user interaction:
- The title of the screen needs a String as its content. Here we can display the title of a photo album or an internationalized string
- The slider that defines a value. Let’s imagine that the interaction with the slider changes the size of the pictures in the main area. Maybe the last value of the slider should be stored on the server to automatically save user preferences
- All pictures in the main area. As you can see each card in this area contains an image and maybe a badge in the top right corner. A badge element in the top right corner visualizes if the photo is flagged.
All properties and collections in Dolphin Platform are observable and therefore it’s quite easy to observe them on the client and the server:
For all client APIs we support first class support for the Dolphin Platform properties. When working with JavaFX for example it’s quite easy and intuitive to bind a synchronized Dolphin Platform property to a JavaFX property:
The main benefit of this concept is that you can use the same model classes on the server and the client. Because the model will automatically be synchronized between the view and the server controller it feels like you work with the same instance. By doing so you can simply bind a string property to a textfield in the view and observe it’s value on the server. The change events will automatically be fired on the server when you start typing in the textfield.
There are a lot of more cool features in the model API but since this should only be a overview I need to stop here But there are only a few weeks left till JavaOne where we will release a whole preview with the source, documentation and several samples. As the next step I will post a preview of the view API the next days.
Today I want to add the next sneak peek of the Dolphin Platform, a new open source project on that Michael Heinrich and I are currently working at Canoo. Yesterday I blogged about the general concept of the platform. Today I want to show server side controllers can be defined by using the Dolphin Platform.
The Controller API
As already said the controller are defined on the server. If you already used JSF you might know this concept. But don’t be afraid, I won’t compare Dolphin Platform with JSF 😉
Each controller must be annotated with the
@DolphinController annotation and therefore the most simple controller might look like this:
Even if this class don’t make that much sense we created a complete runnable Dolphin Platform server application here. Once this is deployed the underlying platform (currently JavaEE or Spring) will automatically find your container and manage its lifecycle. This is done by the architecture of Dolphin Platform that provides a public API and specific bootstrap implementations for JavaEE and Spring. As a developer you will always code against the public API and only need to add the needed bootrap module as a dependency to your server application.
This means that the shown controller will work in any Spring or JavaEE 7 environment.
Since the controllers managed by the container you automatically get all the benefits that comes with it. This means that you can use
@PostContruct annotations, for example:
Next to this Dolphin Platform provides addition features for the controller API. Any method that is annotated by
@DolphinAction can be called from the client view to trigger some actions on user interaction, for example.
By doing so it’s very easy to handle the business logic that will be triggered by a user action. Since the methods are defined on the server you benefit of security and transaction support, for example.
Next to the actions a main concept of the Dolphin Platform is the presentation model (or view model). Each view-controller-pair can define it’s own model that can simply be injected in the controller by using the
@DolphinModel annotation. We will see later how such a model can be defined. When injecting a model to the controller its lifecycle is bound to the lifecycle of the controller and will be automatically managed by the underlying platform.
By doing so the model instance will automatically be created when a new controller instance will be created. If the controller will be destroyed by the container the model will be destroyed, too. In addition the model will automatically be synchronized between the server controller and the view on the client side. How the model can be accessed and handled on the client will part of a future post.
I think the biggest benefit in the shown concept is the perfect integration in a web container like it is provided by Spring or JavaEE. All your controller (and model) instances will be managed by the container and it’s no problem to inject a spring service in your controller, for example. By doing so you can use an API like Spring data and fill your view model directly with data from your persistence.
In the next preview I will show how a view model can be defined by using Dolphin Platform and how you can simply observe any view model on the server and client.
The Dolphin Platform is a framework that implements the presentation model pattern and provides a modern way to create enterprise applications. As you might know there are several of this frameworks out there. So let me start this post by describing what makes the Dolphin Platform special and why we decided to create it.
What we’ve started on the client side will be continued on the server. Here the Dolphin Platform provides an API to create server side controllers that will automatically be managed by the underlying platform. Therefore we create a Spring and JavaEE implementation of the public APIs on server side. As you will see later you can simply inject all your business services in a controller and don’t even think about any lifecycle because the web container will handle that for you. But before I go into the details I want to give a short overview about presentation models and the patterns that are implemented and provided by Dolphin Platform.
Synchronized Presentation Models
In the Dolphin Platform all models will automatically be synchronized between client and server. By doing so you don’t need to think about any specific endpoints or requests.
Based on this the Dolphin Platform defines server side controllers that contains all the controller logic for a specific view. The lifecycle of these controllers is automatically synchronized with the view lifecycle. By doing so you have a MVC group for each client view with a synchronized model and a managed controller.
Ok, I think this was enough description and I hope that you want to see some code 😉 I will post a preview of the controller API, the model API and the view API the next days.
Here are the links to additional DOlphin Platform sneak peeks:
- I blogged about the Dolphin Platform controller API.
- I blogged about the Dolphin Platform model API.
- I blogged about the Dolphin Platform view API.
- I created a first “getting started” tutorial for the Dolphin Platform.
- I blogged about Dolphin Platform Web Frontends with Polymer
- I blogged about the first release of the Dolphin Platform
- I blogged about how to use Dolphin Platform with kumuluzEE
- I was interviewed for the Nighthacking YouTube channel.