JavaFX and Seam with Flamingo
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.
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:
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.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)