Flash Remoting with Java Objects Hosted on the ColdFusion MX Server

In Chapter 27, we talked about ColdFusion MX and Java interaction. We covered several ways in which you can leverage Java in your ColdFusion MX applications, including using the ColdFusion MX server to host Java objects. One of the additional benefits of Flash Remoting’s integration with ColdFusion MX is the ability to have Flash MX communicate directly with these Java objects. To take advantage of this feature, you first need to make sure that the directory where your Java object(s) are stored is registered in the Class Path field under the Java and JVM section of the ColdFusion Administrator. After registering, you’ll need to restart the ColdFusion server for the changes to take effect.

Once the class path is set, any public methods in the Java object are available as methods to your Flash MX movie.[5] If you have a Java object called employee.class in com/example/utils, you could reference a public method called getEmployee( ) from within your Flash movie like this:

#include "NetServices.as" // Call the getEmployee() method on the service specified below myService.getEmployee(); function getEmployee_Result(result) { // ActionScript for handling results returned by the Java object } if (inited = = null){ // do this code only once var inited = true; NetServices.setDefaultGatewayUrl("http://localhost/flashservices/gateway"); var gatewayConnection = NetServices.createGatewayConnection( ); // Note getService() includes ...

Get Programming ColdFusion MX, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.