Contents | Index | Previous | Next

Chapter 1: Connecting to the Tango system

Before any collaboration can take place, one must connect to the Tango runtime. This step, which will be referred to as registering, has to be performed although the Tango itself starts our application. It not only notifies the Tango system that we are joining, but also provides us with a system proxy - the handle to the Tango agent. Here is the implementation:

ex11.html

<html>

<body>

<script language="javascript">

TAgentJS.createTAgentJS(window);

</script>

</body>

</html>

In the script above new variable, Tango_agent is created. Tango_agent is initialized to the value returned by the static method createTAgentJS() of TAgentJS class from webwisdom.tango package. The package is available to the script if the Tango client has been installed. If, for any reason, registration fails, createTAgentJS() will return null. From now on, we will use Tango_agent to access the Tango runtime.

It is a good practice to let the system release the resources. We shall use exitJS() function of Tango_agent when the application is unloaded:

ex12.html

<html>

<body onUnload="Tango_exit()">

<script language="javascript">

function Tango_register(win)

{

Tango_agent=Packages.webwisdom.tango.TAgentJS.createTAgentJS(win);

if(Tango_agent!=null)

Tango_agent.setDbgModeJS(true);

}

function Tango_exit()

{

if(Tango_agent!=null)

Tango_agent.exitJS();

}

Tango_register(window);

</script>

</body>

</html>

Note also that we added setDbgModeJS() call, which will help us trace how Tango_agent interprets arguments we pass. With this option engaged, all calls to Tango_agent will be echoed on the browser's Java console.