Max Katz is a Senior Systems Engineer and Developer Advocate at Exadel. Max is a well-known speaker appearing at many conferences, webinars, and JUG meetings. Max leads Exadel’s RIA and mobile strategy. Part of this role is working as developer advocate for Tiggr Mobile Apps Builder (gotiggr.com), a cloud-based application for building mobile Web and native apps for any device. In addition, Max leads Exadel’s open source projects (exadel.org) such as Fiji, Flamingo, and JavaFX Plug-in for Eclipse. Max has been involved with RichFaces since its inception, publishing numerous articles, providing consulting and training, and authoring the book “Practical RichFaces” (Apress, 2008). Max also co-authored the DZone RichFaces 3 Refcard and the DZone RichFaces 4 Refcard. You can find Max’s writings about RIA and mobile technologies on his blog, mkblog.exadel.com, and you can find his thoughts about these topics and others on Twitter at @maxkatz. Max holds a Bachelor of Science in Computer Science from the University of California, Davis and an MBA from Golden Gate University. Max is a DZone MVB and is not an employee of DZone and has posted 65 posts at DZone. You can read more from them at their website. View Full User Profile

JavaFX and Seam with Flamingo

06.16.2009
| 30441 views |
  • submit to reddit

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

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:

ServiceFactory.setUrl("http://localhost:8080/flamingods/seam/resource/hessian/");
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

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)SeamServiceFactory.getService
(RegisterAction.class, "RegisterAction")).start();
}
public static void stop() {
((RegisterAction)SeamServiceFactory.getService
(RegisterAction .class, "RegisterAction")).stop();
}

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

@Name("registerAction") 
public class ConversationStarter {

@Out
private ConversationObject conversationObject;

@Begin
public void start() {
conversationObject = new ConversationObject();
}
@End
public void stop() {
}
}

Binding

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

Server code:

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

Validation

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);

Summary

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.

 

 


 

 

Published at DZone with permission of Max Katz, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Ayo Bakare replied on Thu, 2009/07/30 - 7:32pm

This makes perfect sence Free Macbook | Free iPhone 3GS

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.