Calling Seam component from JavaFX

To use JavaFX in enterprise, you need to be able to connect JavaFX to enterprise backend such as Java EE, Seam or Spring. Here is an example how to call Seam component from JavaFX using Exadel Flamingo.

Seam component (server side)

@Name("messageManager")
public class MessageManager {

   public String callMe () {
        return "Seam component says: what's up"?;
}

JavaFX (client side)

public interface MessageManager {
   public String callMe ();
}
public class AppServiceFactory {
   public static MessageManager getMessageManager() {
	return (MessageManager) ServiceFactory.getService(MessageManager.class,
		"messageManager");
   }
}

JavaFX script:

var reply : String;
function call(): Void {
     ...
     reply = AppServiceFactory.getMessageManager().callMe();
     ...
}

That’s it. Simple, easy and transparent. Seam is used the same way if you were building a JSF-based application.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s