Accessing the ECL API

When an HTML page that contains an APPLET tag like the one above is loaded by the web browser, the Reflection session launches. When the session has completed its initialization, it loads the module specified by the onStartupJavaClass parameter, in this case, JSEventNotifier.

After the JSEventNotifier module is loaded, it invokes a JavaScript function on your web page called ECLInitComplete, and it passes a reference to the JSEventNotifier class itself. (If you prefer to call the JavaScript function that receives the initial notification something different, specify the function name using the initCallback parameter in the Reflection APPLET tag.)

Once your JavaScript function receives a reference to the JSEventNotifier object, it can obtain the JavaScript API object by calling the getJSAPI() method. It can also use other methods available though the JSEventNotifier module for registering event listeners and setting up screen recognition systems.

The power in using the JSEventNotifier module is that when the ECLInitComplete function in your JavaScript gets invoked, you're assured that the Reflection terminal session is fully initialized and ready for scripting. This means you do not have to poll your Reflection session using the getInitialized() method to determine when Reflection is ready for scripting, making your scripts much more robust and efficient.

NOTE:If you want your script to receive initialization notification but do not need to use the ECL API functions available via the JSEventNotifier module, you can use the lighter-weight notification mechanism provided by the preloadJSAPI parameter. See Using Notification to Determine When Reflection Is Initialized for more information.