Scripting the techexplorer Hypermedia Browser

Bridging Java and techexplorer Add-ins


The feature described is only available in the Professional Edition of techexplorer.

This section describes the methods provided by the ibm.techexplorer.techexplorer Java class for linking techexplorer add-ins and Java applets and JavaScripts. An add-in is a C or C++ software module that can extend techexplorer's ability to process and display various types of data. Indeed, easily connecting web based Java applets and JavaScripts to efficient specialized external applications allows content developers to leverage the strengths of a broad range of applications.

The current version of the techexplorer Java API provides the "glue" for connecting add-ins and Java by providing a conduit betwen the two. The ibm.techexplorer.techexplorer class provides a subset of the add-in Initialization and destruction and Evaluation API, namley addInInitialize, addInShutdown, addInEvaluate and addInBlockingEvaluate.

In what follows, we describe the Java add-in conduit functions as we develop a Java applet for controling the Simple add-in distributed with the professional edition of techexplorer. A JavaScript application for manipulating the Simple add-in is provided as an example in the section detailing the techexplorer add-in architecture. As a final example, we modify the Simple add-in Java applet to support the addInBlockingEvaluate function provided by the Random add-in.

Current Restriction: The techexplorer Java API does not support the creation of add-in instances from Java. As a consequence, calls to addInEvaluate and addInBlockingEvaluate will result in an add-in call to AddInEvaluate and AddInBlockingEvaluate with a NULL instance pointer. Add-ins handle this case by processing the data in a default manner.

Java add-in conduit

The techexplorer Java API provides three methods in the techexplorerPlugin class for interacting with add-ins.

Method Description
int addInInitialize(String mimeType) Start/Initialize a techexplorer add-in if the corresponding add-in is not already active.
int addInShutdown(String mimeType) Shutdown/Destroy a techexplorer add-in.
int addInEvaluate(String mimeType,String appInput) Invoke the AddInEvaluate function of a techexplorer add-in.
String addInBlockingEvaluate(String mimeType,String appInput) Invoke the AddInBlockingEvaluate function of a techexplorer add-in.

An add-in associates the data that it can process with techexplorer by supplying MIME type information. Each of the above methods use the MIME type information for identifying a particular add-in as well as specifying the type of data that will be transmitted. For addInEvaluate and addInBlockingEvaluate, the appInput is the actual data to be processed by the add-in.

The SimpleAddIn applet explained

Here is a skeleton for the SimpleAddin Java applet:

import java.awt.*;
import java.applet.Applet;

import ibm.techexplorer.techexplorer;
import ibm.techexplorer.control.techexplorerControl;
import ibm.techexplorer.axtchexp.AxTchExpRaw;

public class SimpleAddin extends java.applet.Applet {
   ...
   private techexplorer techexplorer = null;

   public void setPlugin( techexplorer obj )
   {
      if ( obj instanceof techexplorer )
         techexplorer = obj;
   }

   public void setControl( AxTchExpRaw obj )
   {
      if ( obj instanceof AxTchExpRaw )
         techexplorer = new techexplorerControl( obj );
   }

   public void init() {
      ...
   }

   public void start() {      
   }

   public void stop() {
   }

   public boolean action(Event evt, Object arg) {
      if ( evt.target == addInInitialize ){
         int nRval = techexplorer.addInInitialize( "application/x-simple-string" );
         switch( nRval ) {
            case techexplorer.ADDIN_SUCCESS:
               simpleAddinLabel.setText( "Simple add-in Control Panel : Loaded" );
            break;
            case techexplorer.ADDIN_ERROR_AVAILABLE:
               simpleAddinLabel.setText( "Simple add-in Control Panel : Simple add-in not available" );
            break;
            case techexplorer.ADDIN_ERROR_LOAD:
               simpleAddinLabel.setText( "Simple add-in Control Panel : can not load Simple add-in dll" );
            break;
            default:
               simpleAddinLabel.setText( "Simple add-in Control Panel : Not Loaded" );
            break;
         }
         return true;
      } else
      if ( evt.target == addInShutdown ){
         techexplorer.addInShutdown( "application/x-simple-string" );
         simpleAddinLabel.setText( "Simple add-in Control Panel : Not Loaded" );
         return true;
      }
      else
      if ( evt.target == addInEvaluate ){
         if ( techexplorer.addInEvaluate( "application/x-simple-string", evalTextField.getText() ) != techexplorer.ADDIN_SUCCESS )
               simpleAddinLabel.setText( "Simple add-in Control Panel : evaluate failed" );   
         return true;
      }
      else
         return false;
   }
}

Comments:

Note that the MIME type used to describe the add-in input is application/x-simple-string. The simple add-in interprets this MIME type to indicate that the data to be processed is included in the string.

Try out the SimpleAddin applet!








Click here for the whole program. Note that since some browsers do not support Java 1.1, the SimpleAddin applet is Java 1.0 compliant.

Try out the RandomAddin applet!

Try out the RandomAddin applet. Each evaluation produces a random integer displayed in the techexplorer window.





Click here for the whole program. Note that since some browsers do not support Java 1.1, the SimpleAddin applet is Java 1.0 compliant.


Click here to to view the previous section. Click here to to view the next section.

IBM techexplorer Hypermedia Browser is a trademark of the IBM Corporation. Send comments and questions to techexpl@us.ibm.com.