Java Applets as Data Providers

To date, MSHTML, which was introduced in Microsoft Internet Explorer 4.0, has supported Microsoft ActiveX Controls as data providers when they are present on an HTML page, and also when the control supports either the OLE-DB Simple Provider interface or is an instance of the Advanced Data Connector (ADC), which provides OLE-DB interfaces. Note that ADC is the only OLE-DB interface supported in release 1.0 of Internet Explorer 4.0/MSHTML. As Java becomes more prevalent on the Internet, it will be desirable for Internet Explorer 4.0/MSHTML to support writing data sources in Java using JavaBeans.

The remainder of this article specifies the conventions to be used when constructing data-providing applets in Java. The internal Internet Explorer 4.0/MSHTML data binding agent implements support to detect and utilize such applets similar to the current support for ActiveX Controls.

  • Overview
  • Recognizing Java Applets as Data Providers
  • Notifications for Data Set Changes

Overview

Although Internet Explorer 4.0/MSHTML 1.0 will only support third-party providers that implement the OLE-DB Simple Provider interface, this specification is constructed to allow support for additional provider types when Internet Explorer 4.0/MSHTML adds support for those providers. All references to the OSP interfaces in this specification can be summarily changed to any of the additional provider interfaces supported by Internet Explorer 4.0/MSHTML.

Recognizing Java Applets as Data Providers

The applet writer needs a way to allow the Internet Explorer 4.0/MSHTML binding agent to detect the Java applet as a data provider. The most straightforward way to accomplish this is for the applet to implement a well-known method that the Internet Explorer 4.0/MSHTML binding agent will call to recognize the applet. The method will have the following signature:

public Object msDataSourceObject( String qualifier );

The qualifier parameter will be used when a data-providing applet supports access to more than one set of data. When the parameter is NULL or a null string (""), the applet should return the data interface on its default data set. What constitutes the default data set is left to the applet.

Note  Internet Explorer 4.0/MSHTML 1.0 will only support applets that provide a single data set; therefore, it will use only the msDataSourceObject("") form of the call when invoking the interface.

Notifications for Data Set Changes

There are instances where a consumer already has an interface to a data set supplied by an applet, and the shape of the data set changes. For example, the number of columns changes, the names of the columns change, the type of column changes, or the entire data set is reordered (as the result of a sort operation). In such an instance, there needs to be a way for the consumer to get notified of the change so it can retrieve a new interface on the (changed) data—using a call to msDataSourceObject. Consumers will do this by registering with the provider for a notification.

The applet must support a method whereby the consumer can register for receiving such notifications. The method has the following signature:

public void addDataSourceListener( DataSourceListener listener )
    throws java.util.TooManyListenersException;

IDataSourceListener is defined as follows:

public abstract interface DataSourceListener
{
   void dataMemberChanged( String qualifier );
   void dataMemberAdded( String qualifier );
   void dataMemberRemoved( String qualifier );
}

When a data change occurs, the applet will call the dataMemberChanged method on the DataSourceListener interface to notify the data consumer that the shape has changed. The qualifier will indicate which data interface has changed (for Internet Explorer 4.0/MSHTML 1.0, this will be ignored since data sources can only expose a single data set).

Finally, a data consumer must notify a provider that it is no longer interested in data-shape-change notifications by calling the following method:

public void removeDataSourceListener(
    DataSourceListener listener);

The DataSourceListener should be identical to the one passed to addDataSourceListener.