Accessing the ECL API from JavaScript

Even if you're not a Java programmer, you can still take advantage of many of the powerful features of the Reflection Emulator Class Library (ECL).

JSEventNotifier, a built-in module provided with Reflection for the Web, integrates many features of the Reflection ECL API with the LiveConnect features of JavaScript. When you use the JSEventNotifier module, you can write JavaScript code that registers listeners to receive event notification from the Reflection ECL; in many ways, this makes your JavaScript code act similar to a Java applet.

The JSEventNotifier module works as an ECL "attachment" class, a type of custom Java module that attaches itself to an existing Reflection session after the session has been initialized. Attachment classes usually fall into two categories:

  • Macro-like attachments, which are invoked on demand to perform a single task.

  • Monitor-like attachments, which are loaded during the session but don't perform any action until some event occurs or some screen appears, at which time they perform their task.

These types are not exclusive; an ECL attachment class may act like a macro initially, then wait and watch for a particular screen in order to perform another task.

Because the JSEventNotifier module uses LiveConnect, it can send messages to your waiting JavaScript; that means you don't have to write JavaScript code that continually polls the terminal session to determine if new data has arrived or if the connection state has changed.