Web Browser Plug-in for Dolphin applets

The web browser plug-in allows Dolphin applets to be dynamically downloaded to a client's machine and displayed within an Internet browser. The plug-in is a single DLL which consists of a VM and a standard image. An applet is a set of classes individually saved in a binary format which can be dynamically downloaded into a running plug-in on the users machine where they execute. The applet may be generated from a pre-existing application with no or minimal modifications, or be aimed exclusively for use in a browser where it may use the majority of the Plug-in API supported by Netscape 3.0.


Plug-in

The Dolphin plug-in consists of a single NPDolphin.DLL which is composed of a VM and an image. It is effectively the DolphinPxxx.DLL and Dolphin.IMG files wrapped up into one file with a suitable interface onto an internet browser. The image comes with the Plugin and Sockets packages loaded so you can use the functionality of these without the overhead of downloading them.

Installing

The principle act of installation is to copy the NPDolphin.DLL into the 'plugins' subdirectory of the internet browser. Any DLL in this directory whose name is prepended with 'NP' is effectively registered by the browser, though older browsers may require you to restart them first. If you have both Netscape Navigator and Microsoft Internet Explorer installed on your machine, placing the plug-in within the Navigators subdirectory will allow the Internet Explorer to additionally use it, but the reverse is not the case.

For the end user there is a self extracting executable which will install the plug-in for the desired browser and also attach an uninstall option. You may redistribute this. You can also use assisted installation to prompt users with the location of the plugin executable if they do not have it installed when they try and use a page containing an embedded Dolphin applet.

Compatibility

The Dolphin plug-in is compatible with Netscape Navigator 2 & 3 and Microsoft Internet Explorer 3. It should also work with all other browsers supporting at least the Netscape 2 plug-in API. Note that the Navigator 2 release does not support the assisted installation facility.

Creating the plug-in

It is not possible to create your own plug-in DLL. New versions of the plug-in will be released to coincide with releases of Dolphin or modifications to the Plugin package.

Memory residency

A browser will only open one instance of the Dolphin plug-in at any time. So a number of applets on the same page, or even different pages will all be loaded and executing within the same plug-in. The plug-in will stay loaded as long as any applets are running. On closing the last applet, by changing pages or closing a browser window, the plug-in will be unloaded from memory. This would happen if you went from one page containing an applet to another page containing an applet, while no other pages were open containing applets. When the plug-in is unloaded the current state of the image is not saved, so the plug-in is fresh each time it is loaded in.


Applets

An applet consists of a number of downloadable classes which fill a visible rectangle within a page displayed in an Internet browser. Any number of applets may be present on a single page, all executing within a single plug-in.

Deploying an Applet

The classes of an applet are individually saved in binary format with the STC extension. They are generated by choosing File/Save Binary Classes of the Package Browser or Class/Save Binary Class of the Class Hierarchy Browser. The STC format includes only the name of a class, its compiled methods, contents of class variables and class instance variables. As such it does not replace the existing package output and is useful only for final deployment of applications.

All class files necessary for an applet have to be positioned within the same directory. It is not possible to reference classes within other directories or machines.

Interface with Plug-in

For an application to work as an applet one of its classes must define a #showInPlugin: class method. This is the first class file which is downloaded onto the users machine and its #showInPlugin: method should initialize the applet and add a view to the browser. There are suitable methods in the View and Presenter classes which should be sufficient for most applications. The Presenter version opens the defaultView onto a defaultModel of the class.

A lot of the classes referenced in the applets first file will not be present in the plug-ins image, and so a proxy is held in their place. Only when a message is sent to the classes proxy will the class be downloaded onto the users machine. If a class is never used during an execution then it will not be loaded into the plug-in. Most internet browsers keep a cache of the last few megabytes of downloaded files so for repeated use of an applet the class files should already be present on the machine so decreasing the time to load it.

The argument to the #showInPlugin: method is an AppletContext which defines the interface between an applet and the internet browser. The AppletContext class is defined within the Plugin package, but unless you are writing an applet which makes use of additional plug-in capabilities the important point is that it answers the #site message with a ContainerView suitable for adding the applet's view to. You should not resize the supplied container view as it is dictated by the internet browser.

You will find that there is probably no point trying to place a Shell or ShellView within the browser window. Most importantly there will be no menu bar, and secondly some of the controls will not respond properly to mouse clicks.

Applet Appearance

There are two types of applet appearance, full page and embedded. Supplying the web address of a STC file will produce a full page applet consuming the whole area of the browser window. The embedded applet occupies a rectangle of fixed extent on the browsers window and is introduced with the EMBED tag in an HTML page.

Embed tag

This is an HTML tag which introduces an applet of fixed extent on a web page. The Embed tag supports a number of standard attributes for defining an applet.

An example for putting a scribble pad of 500 by 100 pixels within an internet browsers page is:

<EMBED
	SRC=ScribblePresenter.stc
	WIDTH=500
	HEIGHT=100
	PLUGINSPAGE=DownloadDolphinPlugin.htm
	TYPE=application/x-dolphin-class
>

The SRC standard attribute specifies the location of the class which will respond to the #showInPlug: message. The class file may be positioned either relative to the HTML page or absolutely. Dolphin uses STC binary class files which are associated with the 'application/x-dolphin-class' MIME type.

The WIDTH and HEIGHT standard attributes define the extent of the applet. These values are measured in pixels.

The PLUGINSPAGE standard attribute is used with assisted installation. If the Dolphin plug-in has not been installed the browser will go to the supplied page which should document the process of installing the plug-in.

The TYPE standard attribute informs the browser of the MIME type of the SRC file. Generally this is not needed as the browser will use the extension of the SRC file to work this out, but Netscape Navigator will go by the MIME type of the SRC file as supplied by the web server in preference unless it is explicitly set by a TYPE. If the server does not have an association of application/x-dolphin-class for STC files then it will return a default, such as text/plain, which is not very useful. As a result you will have to include either this TYPE entry, or setup your server with a suitable association. You will see that the server has a hundred or so of these associations already defined.

It is possible to include private attributes. These will be ignored by the plug-in but are available to the applet through the #attributes method of AppletContext.


Example Scribble Applet

As a small example we will generate an applet for the Scribble application, which comes with the Dolphin release in the Samples subdirectory. Firstly install the Scribble.PAC file by using the Package Browser. If you choose the Class tab of the package browser once its loaded you will see that the scribble package consists of two classes, ScribblePresenter and ScribbleView.

To see the scribble pad in action, evaluate the following:

	ScribblePresenter show

To produce a version of the scribble for deployment as an applet select the Scribble package in the Package Browser then choose File/Save Binary Classes. This will produce two binary class files in the current directory, ScribblePresenter.stc and ScribbleView.stc.

To see the scribble pad embedded in the internet browsers page we must include a suitable embed tag in an HTML page. Save the following simple page as a .htm file in the same directory which the stc files have just been saved to.

<html>
	<head> <title>Scribble Applet</title> </head>

	<body>
		<h1>Scribble Applet</h1>
		<p>Here is an example of a Dolphin applet embedded in a html page.</p>
		<hr>

		<EMBED
		        SRC=ScribblePresenter.stc
		        WIDTH=450
		        HEIGHT=200
		        PLUGINSPAGE=DownloadDolphinPlugin.htm
			TYPE=application/x-dolphin-class
		>
		<hr>
	</body>
</html>

Now when you load the htm file into your internet browser you should see the scribble pad embedded in the html page. If you have not installed the Dolphin plug-in the browser will attempt to show the DownloadDolphinPlugin.htm page, which in this example does not exist, but in real life would prompt users to download and install the plug-in.

A demonstration of this is available on the Object Arts website.

The scribble pad can also be displayed in full page mode by simply opening the ScribblePresenter.stc file in the browser.


Current Limitations

There are some display problems caused by rapid scrolling within the web browser.

No support for Netscape LiveConnect. This would allow Dolphin to call out, and be called from Java.

No authentication of downloaded applets.

No support for automatically retrieving newer versions of the plug-in.

No support for marking versions of applets and their prerequisites..

Cannot extend plug-in to handle other MIME types.

Cannot use HIDDEN embed attribute.