Attachmate Worldwide  |   Contact Us  |   NetIQ.com
Home » Support » Solution Library

Technical Notes

Reflection for the Web API Session Initialization
Technical Note 2246
Last Reviewed 11-Apr-2008
Applies To
Reflection for the Web version 9.0 or higher
Summary

Reflection for the Web provides an extensive API (Application Programming Interface) that enables users to automate many tasks. This technical note demonstrates the preferred method for ensuring that the Reflection for the Web session is initialized before calling methods on the API.

Determine that the Session is Initialized

Use one of the following options to determine if the session is initialized.

  • Use the ECLInitComplete Javascript function invoked from a JSEventNotifier module loaded from the Applet "onStartupJavaClass" parameter. The ECLInitComplete function is only invoked after the terminal session is fully initialized, so no polling is necessary.

This is the preferred method for determining that the session is initialized.

  • Call a Javascript function from the page "onload" event and poll the Applet API getInitialized() method.

For more information about the JSEventNotifier, see the Reflection for the Web Software Development Kit (SDK) or view the "Using Notification to Determine When Reflection is Initialized" sample in the "API Examples" section of the Reflection for the Web help.

Call the Reflection API

When using the Reflection API to create automated login tasks, it is important to ensure that the Reflection API is initialized before the API call is made, or the login task will fail.

Use one of the following options to call the Reflection for the Web API.

  • "notifier.getECLSession()getJSAPI();"

This is the preferred method for calling the API.

  • "document.IBM3270.getAPI("JSAPI","IBM3270");"

This method is less reliable, as it may fail to load the API in some conditions, such as on page reload.

Sample Script

The following sample script uses the ECL attachment class JSEventNotifier to make sure the session is fully initialized, then calls the Reflection for the Web API using "notifier.getECLSession()getJSAPI();"

Note: To use this sample, change the hostURL parameter in the <applet> tag to a host appropriate for your network.

<html>
<head>
<title>Example of using Notification to Determine Reflection Initialization</title>
<script language="JavaScript">
<!--

   /*
      Variable to hold the API reference when it's retrieved.
   */
   var api = null;
   
   /*
      ECLInitComplete is the predefined name of the function
      that the com.wrq.eNetwork.ECL.modules.JSEventNotifier 
      module calls when Reflection initialization is complete.
      It passes a reference to itself, which is not needed here.
   */
   function ECLInitComplete( notifier )

   {
      api = notifier.getECLSession().getJSAPI();

      if ( api == null )
      {
         alert( "Reflection API initialization failed." );
      }
      else
      {
         doSessionSetup();
      }
   }

    /*
       This function calls Reflection's showDialog method to
       open the Session Setup dialog box. This function is 
       invoked only after notification is received that the 
       terminal session has been initialized.
    */
    function doSessionSetup()
    {
       api.showDialog( "sessionConfigure" );
    }
// -->
</script>
</head>
<!-- 
   The onLoad event handler is used to execute the JavaScript 
   code after the page is loaded.
-->
<body>
<!--
   This is the tag that launches a Reflection IBM 3270 applet.
   The archive attribute is used for Netscape browsers,
   while the cabbase parameter is used for Internet Explorer.
   To use this example, change the hostURL parameter to one
   appropriate for your network.
-->
<applet mayscript name="IBM3270"
        codebase="./ex/"
        code="com.wrq.rweb.Launcher.class"
        width="666" height="448"
        archive="Launcher.jar">
    <param name="hostURL" value="tn3270://accounts">
    <param name="autoconnect" value="false">
    <param name="cabbase" value="Launcher.cab">
    <param name="launcher.sessions" value="IBM3270">
    <param name="onStartupJavaClass" value="com.wrq.eNetwork.ECL.modules.JSEventNotifier">
    <param name="preloadJSAPI" value="true">
</applet>

</body>
</html>

Related Technical Notes
1776 Programmatically Controlling Reflection for the Web Framed Sessions
2183 Developer Tools for Attachmate Products
9988 Reflection for the Web Technical Notes

Did this technical note answer your question?

Yes    No    Somewhat     Not sure yet

Additional comments about this tech note:

Need further help? For technical support, please contact Support.