JavaFX and Seam with Flamingo

DZone 's Guide to

JavaFX and Seam with Flamingo

· Java Zone ·
Free Resource

This is a two part article (part two) that will demonstrate how to use JavaFX and Seam with the Flamingo RIA framework. The article assumes that you have a basic familiarity with JavaFX and Seam.

JavaFX was released in December 2008 and has received its own measure of approval and disapproval as virtually any major new technology will. I will let you decide for yourself into which camp you belong. I believe JavaFX is a great technology for creating rich Internet applications. It is not going to replace the browser (AJAX applications) but there are instances where JavaFX is a better fit then AJAX-based UIs. Having said that, one critique that I have is that there is virtually no mention of JavaFX and server-side integration. There are numerous examples of shapes, moving and bouncing around. There are also examples of games, but none show any enterprise level server-side integration. Enterprise-level applications are usually form-based. This article shows how Flamingo fills in this gap by letting you easily connect JavaFX with Seam or Spring back-ends.


JavaFX is a new rich client platform for building and delivering Rich Internet Applications that run inside the Java virtual machine. JavaFX Script, one of its main components, is a new declarative language for building rich interfaces. In this article I will refer to JavaFX Script as JavaFX.

Although I said that everything is new, it's not entirely true. One way to look at JavaFX is that it's Applets reborn and better (if you don't remember Applets, then all the better for you). Problems such as challenging runtime installation, runtime download size, and slow application start up time existed with the old Applets, problems which are now fixed in JavaFX. JavaFX provides a declarative way to define the UI, easy runtime installation and update, and quicker application start up time.

Furthermore, JavaFX applications can be deployed and run inside the browser (Java runtime installed as plug-in) via Java Web Start and standalone applications. Given that JavaFX applications are compiled and run inside the Java virtual machine, a richer user experience can be delivered, unlike the standard Web browser scenario where markup (HTML) and JavaScript are interpreted.

JBoss Seam

Seam is a lightweight framework whose goal is to make Java EE development simpler. To be more specific, it greatly simplifies development by unifying JSF and JBoss RichFaces with EJB3, JPA, or Hibernate. Out of the box, Seam works with JSF and RichFaces. (GWT supports also exists.)

JavaFX with Seam

One question that remains unanswered is how we could use JavaFX with Seam. In other words, how does one build a user interface with JavaFX (deploy it as Applet, Web Start, or even standalone) and connect it to a server-side running JBoss Seam? Because JavaFX seamlessly integrates with any Java class (after all, it's based on Java) we could build our own communication protocol to talk to Seam. I'm pretty sure most of you grinned at this idea. Who would want to start building their own communication protocol? Luckily a solution exists. The solution has actually existed since June 2008. Now that JavaFX is more mature and gaining momentum, it is the perfect time to revisit the solution.


Exadel Flamingo is a tool for easily bootstrapping JavaFX with a Seam/Spring back-end. (Remember though, we are concentrating on Seam in this article.) It has three main features:

CRUD Tools

Flamingo provides the ability to quickly generate a CRUD-type application with entities, a database, and a user interface. This is important because putting together a Java EE Web project has become quite a challenge. There are so many different way to configure the project and numerous dependencies to resolve. With Flamingo tools, you can not only create a new project quickly, but also generate pieces of an application on demand over the course of the development cycle. If you have ever used the seam-gen tool to generate a Seam project, well, Flamingo provides similar tooling.

An Integration Library

It serves as the glue between the JavaFX client and the Seam server code working behind the scenes, so the developers can concentrate on business problems instead of writing “plumbing” code. Additionally, communication between JavaFX and Seam is done via binary protocols. (They are the most efficient.) For JavaFX-to-server communication, the Hessian protocol is used.

Client-Side Components

These are non-visual client components that make development easier by providing validation, binding, and the ability to call methods on Seam components. Let's look at these components in more detail.


ServiceFactory (com.exadel.flamingo.javafx.ServiceFactory) helps to easily create proxy objects on the client-side. Once proxy objects have been created, it's possible to call any methods on the Seam component. For example, in the JavaFX client:

RegisterAction registerAction = (RegisterAction) ServiceFactory.getService(RegisterAction.class, "registerAction");

RegisterAction is an interface on the client side and registerAction is Seam component name. Now you can call any methods on registerAction component from the client.


SeamServiceFactory (com.exadel.flamingo.javafx.SeamServiceFactory) is very similar to ServiceFactory but, in addition, creates a client proxy object that automatically supports Seam conversations when performing a server call. You can start/stop a Seam conversion running on the server.

For example, to start/stop a conversion on a client side:

 public static void start() { 
(RegisterAction.class, "RegisterAction")).start();
public static void stop() {
(RegisterAction .class, "RegisterAction")).stop();

RegisterAction is an interface on the client side. And on the server side it's a plain Seam component:

public class ConversationStarter {

private ConversationObject conversationObject;

public void start() {
conversationObject = new ConversationObject();
public void stop() {


As the name implies, this component allows binding to a Seam component in one of the Seam contexts from the JavaFX client.

Server code:

private ArrayList <Car> carList;

Client code: 

ArrayList <Student> carList = (ArrayList<Car>)getBindingManager().getObject("carList");

Car is an interface on the JavaFX side. It's also possible to commit an object modified in JavaFX back into a Seam context:

Client code:

getBindingManager().commit("user", newUser);

On the server, a user component will be found in one of the Seam contexts and replace newUser.


This component allows validating user input against Hibernate Validator annotations on the server. Seam component with Hibernate Validator annotations:

@Name ("user") 
public class User {

@Length(min=3, max=40)
private String name;

On the client side, Flaming provides a built-in JavaFX validator component. In the code below, user is Seam component name and name is component property (see above):

message = FlamingoServiceFactory.getHessianEntityValidator().
validate("user.name", inputText.text);


Part 2 of this series will show how to build an example step by step where we use JavaFX and Seam. Hopefully this article has shown you how simple, easy, and transparent it is to build JavaFX rich clients that are connected to enterprise back-ends such as Seam.

Max Katz is a senior system engineer at Exadel. He is the author of “Practical
RichFaces” (Apress) and co-author of RichFaces DZone RefCard.  He has written numerous articles, provided training, and presented at many conferences and webinars about RichFaces and RIA technologies. Max blogs about RichFaces, JavaFX and RIA technologies at http://mkblog.exadel.com.






Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}