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