Programmatically Controlling Reflection for the Web Framed Sessions
Technical Note 1776
Last Reviewed 30-May-2008
Applies To
Reflection for the Web 2008 (All Editions)
Reflection for the Web version 8.x through 9.x
Summary
This technical note describes how to programmatically control Reflection for the Web sessions running outside of browser windows; in this note, these sessions are referred to as "framed sessions." For demonstration purposes, the note uses JavaScript and the Reflection for the Web application programming interface (API) to control Reflection.
In addition, custom Jscript, VBScript, Java applets, and Java applications can use the Reflection for the Web API to control Reflection applets. (For more information about the Reflection for the Web API, see the "Scripting with the Reflection API" section in the Administrative WebStation.)
Note: This note covers controlling framed Reflection sessions. For information about controlling sessions embedded in browser windows, see Technical Note 1773.
Controlling a Single Framed Session
A framed Reflection for the Web session can be controlled by script code residing in a JavaScript (*.js) file. Follow the steps below to control a single framed Reflection for the Web session.
- To access the Administrative WebStation, follow these steps:
- In your web browser, access the Reflection for the Web links list page (where your available Reflection for the Web sessions are listed) at:
https://<your server>:<HTTPS port number>/<management server context>/AdminStart.html
For example, if the server is www.ourcompany.com and the management server context is rweb (the default), the URL is
https://www.ourcompany.com:843/rweb/AdminStart.html
Alternately, you may be able to access the links list page by clicking Start > Programs > Reflection for the Web > Administrative WebStation.
- Log on with your administrator password and click the Administrative WebStation link.
- In the Reflection for the Web Administrative WebStation, open the Session Manager tool.
- Configure a Reflection session to automatically run JavaScript code on startup. In the Session Manager:
- Either open an existing terminal session or create a new terminal session. Make note of the session name you want to programmatically control.
- Verify that the "Display session in its own window" option is selected.
- Click Applet Parameters. Under the "Add parameters" section, click the Parameter drop-down list, select onStartupJavaClass, and type com.wrq.eNetwork.ECL.modules.JSEventNotifier for the value.Click Add.
- Click the Parameter drop-down list again, select preloadJSAPI, and type true for the value. Click Add.
- Under the "Custom parameters" section, type initCallback in the Parameter field and type the session name you noted in step 3a in the Value field. Click Add.
- Click Continue at the bottom of the page.
- Click Save Settings on the next page.
- Create the JavaScript code that will control Reflection for the Web. For example:
In the example, the session_name placeholder (listed twice) is the Reflection session_name as it appears in the Links List and Session Manager. However, the JavaScript function name does not need to match the session name, but the JavaScript function name does need to match the initCallback value as defined in step 3e above. (The initCallback value is a reference to a JavaScript function.)
- Save your JavaScript file as plain text with a .js extension to <path to Reflection for the Web application context>\webapps\rweb\. In a default Windows installation, the path to this folder is:
C:\Program Files\ReflectionServer\jakarta-tomcat\webapps\rweb\
- Edit the LauncherHTML.jsp page in the <path to Reflection for the Web application context>\webapps\rweb\WEB-INF\jsp directory. In a default Windows installation, the path to this folder is:
C:\Program Files\ReflectionServer\jakarta-tomcat\webapps\rweb\gm
- In the LauncherHTML.jsp file, add the below line to the <head> section of the HTML code and save the LauncherHTML.jsp file. Make sure to save the file as plain text. The script name placeholder is the script name defined in step 5.
<script language="JavaScript" src="./[script name].js"></script>
- Access the Links List and click the modified Reflection session. After the Reflection applet is initialized, the JavaScript should run.
Controlling Multiple Framed Sessions Individually
If you want individual framed sessions to run specific JavaScript code, follow the steps below.
- Follow steps 1-8 in the previous section to control one framed session.
- Create or edit a new framed session in the Session Manager.
- Configure the newly created additional Reflection session to automatically run JavaScript code on startup. Follow these steps in the Session Manager:
- Select the session you want to control. Make note of the session name.
- Verify that the "Display session in its own window" option is selected.
- Click Applet Parameters. Under the "Add parameters" section, click the Parameter drop-down list, select onStartupJavaClass, and type com.wrq.eNetwork.ECL.modules.JSEventNotifier for the value. Click Add.
- Click the Parameter drop-down list again, select preloadJSAPI, and type true for the value. Click Add.
- Under the "Custom parameters" section, type initCallback in the Parameter field and type the session name you noted in step 3a above in the Value field. Click Add.
Note: If you want to control all framed sessions with the same JavaScript function, make the initCallback value identical for all sessions. When multiple sessions use the same initCallback value, the same JavaScript function is called in all sessions and the same code is run.
- Click Continue at the bottom of the page.
- If you modified an existing session, click Save Settings on the next page. Note: If you’re creating a new session, you’ll need to launch the session first before you can save the settings.
- Edit your JavaScript (*.js) file as defined in the previous section. This file resides in <path to Reflection for the Web application context>\webapps\rweb\. In a default Windows installation, the path to this folder is
C:\Program Files\ReflectionServer\jakarta-tomcat\webapps\rweb\
- Create another JavaScript function that will control the second Reflection session. In the second JavaScript function, define a new function name and a new session name. The session name in the getAPI method must match the session name as it appears in the links list and in the Session Manager. See the following example code:
- Save your JavaScript (*.js) file.
- Access the links list and click the second Reflection session. After the Reflection applet is initialized, the JavaScript should run.
Related Technical Notes
| 1773 |
Programmatically Controlling Reflection for the Web Embedded Sessions |
| 2183 |
Developer Tools for Attachmate Products |
| 9988 |
Reflection for the Web Technical Notes |