• Home
  • Events
  • About
  • Dolphin Platform Web Frontends with Polymer

    October 22nd, 2015

    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:

    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:

    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.

    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 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.

    Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
    • email
    • Print
    • Twitter
    • LinkedIn
    • XING
    • Facebook
    • Google Bookmarks

    Our JavaFX RefCard was published

    October 18th, 2015

    Refcard Cover

    Hendrik and Michael Heinrichs created a RefCard for JavaFX 8, which was published today. A big thanks goes to the people at Dzone, who made this happen. You can download the RefCard over at JavaFX 8 RefCard.






    Excerpt of controls overview

    The RefCard gives a quick overview of the most important features in JavaFX 8. For example there is a collection of screenshots from all controls that are available. You can see an excerpt to the left. This will make it easy for you to find any control that you need.







    Another example is the image to the right which is a quick reference to all the ways how you can style a JavaFX stroke.





    We hope you enjoy it.

    JavaFX 8 RefCard

    Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
    • email
    • Print
    • Twitter
    • LinkedIn
    • XING
    • Facebook
    • Google Bookmarks

    Dolphin Platform: How to create an application

    October 16th, 2015

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

    The calculator application

    The application we will create in this post might not be the coolest one but it gives you a good overview of the Dolphin Platform concepts and APIs. The final application should calculate the sum of two 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. Additionally, we are going to 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 not be very useful for this small example but think about bigger applications with complex calculation or a persistence layer. Plus, 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 we will create a client only application by using JavaFX. That’s why we decided to use an example that normally doesn’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

    First, we 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:

    Now, we need a controller class that adds some interaction and bindings to our view. In JavaFX, you can create a view by bundling a controller class and an 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 we already added a initialize() method that will automatically be called by JavaFX after all controls have been injected in the controller instance. Unfortunately, this is done by some kind of magic and JavaFX doesn’t provide a 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. We 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 we 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 @PostConstruct 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 @PostConstruct is handled.

    Once this is done we need to add some additional features to the controller class. Let’s start with the calculation. 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. We now 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:

    We will define the content of the init() method later and finish the application class first. 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.

    We will blog in more detail about all these benefits in future posts.

    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 we 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 weI plan to add a post about Polymer based clients and how you can create web clients by using the Dolphin Platform.

    Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
    • email
    • Print
    • Twitter
    • LinkedIn
    • XING
    • Facebook
    • Google Bookmarks

    Basilisk 0.0.0 released!

    October 12th, 2015

    It’s here! Basilisk 0.0.0 has just been released! You can grab it from Bintray and JCenter immediately!

    Following the steps of the first Griffon release (0.0 back in 2008) Basilisk brings high productivity and fun to mobile/desktop JavaFx application development. This release includes the following goodies:

    Want to take it for a spin? Here’s how you can get a Basilisk application running in no time

    The recommended way to get started with a Basilisk project is to use a Lazybones project template and Gradle. You can install these tools with SDKMAN.

    $ curl -s http://get.sdkman.io | bash
    $ sdk install lazybones
    $ sdk install grade

    Next register the basilisk-lazybones-templates repository with Lazybones’ config file. Edit $USER_HOME/.lazybones/config.groovy

    bintrayRepositories = [

    List all available templates by invoking the following command

    $ lazybones list
    Available templates in basilisk/basilisk-lazybones-templates


    Select a starting template from the list and invoke the create command

    $ lazybones create basilisk-javafx-ios sample

    Compile, run and test the project with any of these commands

    $ gradle build
    $ gradle test
    $ gradle run
    $ gradle launchIPhoneSimulator

    Also have a look at basilisk-samples, a repository that will contain reference and sample applications as time passes by.

    If you decide to give it a try, do let us know what you think at the mailing list, issue tracker and/or @basilisk_fw.

    Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
    • email
    • Print
    • Twitter
    • LinkedIn
    • XING
    • Facebook
    • Google Bookmarks

    And Griffon beget Basilisk

    October 9th, 2015

    I’ve been keeping an eye on JavaFXports ever since Johan announced the project. From time to time I test the latest builds to see how the project grows. A few months ago we had a breakthrough with Griffon and the jfxmobile plugin; after a few tweaks (and some API changes from Griffon’s side) it was clear that running Griffon on an iOS device was no longer a wild dream, but rather a reality.

    So what about those API changes? There were actually not that widespread, actually they were concentrated to a particular set of common, standard APIs that every Java SE developer knows and encounters almost ever single day: the java.beans package. For historical and practical reasons RoboVM relies on the Android SDK to enable Java (and JavaFX) to run on Android and iOS devices. This brings along some of the restrictions Android users know by heart: black listed classes such as the ones contained in the aforementioned package. The only way to make things work was to replace the black listed API with something that’s functionally equivalent but with a different name, and so openbeans got into the picture. Funny thing, this package contains code from Apache Harmony, the alternate “Java” implementation that never was.

    Anyway, it was clear that a breakage in compatibility was needed in order to allow Griffon applications to reach out into the mobile space with JavaFXports’ help. We’re over a year now since Griffon 2.0.0 was released; the 2.x line broke compatibility with the previous series, and the team thinks we still have a few more releases before we decide to break compatibility again for 3.0.0, if needed be. But we don’t want to wait long in order to enjoy the benefits of Griffon on mobile, so we came up with a different plan: fork Griffon.

    Basilisk is a fork of the Griffon 2 codebase (2.5.0-SNAPSHOT as we speak) that aims to bring the Griffon experience to mobile/desktop application development. Basilisk targets Java8 and JavaFX8 specifically, any Java developer will be able to pick it up quite easily.

    For now, the differences between Griffon and Basilisk are minimal, besides the package renaming and the usage of openbeans almost everything else is the same. Migrating between one framework to the other can be done with a small set of steps:

    • s/org.codehaus.griffon/org.kordamp.basilik/
    • s/griffon/basilisk/i

    We expect Basilisk to grow on its own, sporting features that make sense for desktop and mobile environments. It will be possible to migrate features between Griffon and Basilisk, so that porting applications will remain an easy task. While Griffon remains as the preferred solution for building all kind of desktop applications, from the very small to the full fledged, enterprise ready ones, we foresee Basilisk taking its place as the choice for developers that need to build applications that cross between desktop and mobile spaces.

    There’s no release yet for Basilisk; there are still some migration aspects to be taken care of, such as the guide and documentation, however you can take Basilisk for a spin right now by simply cloning https://github.com/basilisk-fw/basilisk.git and building your own version. It’s as simple as

    $ curl -s http://get.sdkman.io | bash
    $ sdkman install gradle
    $ git clone https://github.com/basilisk-fw/basilisk.git
    $ cd basilisk
    $ gradle publishToMavenLocal
    $ gradle installAllTemplates

    After this you can use the provided templates to create and test an application

    $ sdkman install lazybones
    $ lazybones create basilisk-javafx-ios 0.1.0-SNAPSHOT sample
    $ cd sample
    $ gradle launchIPhoneSimulator

    Don’t be fooled by the low version number, Basilisk comes from a fine codebase lineage that includes Griffon (2008) and Grails (2005), it’s pretty mature as you will see.

    These are exciting times to be building Java(FX) applications for desktop and mobile.

    Keep on Groovying!

    Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
    • email
    • Print
    • Twitter
    • LinkedIn
    • XING
    • Facebook
    • Google Bookmarks