BeanInfo
class that describes the applet's properties, methods, and events. VJS uses BeanInfo
class information to display information about the object at design time. If an applet does not provide optional BeanInfo
information, VJS supports automatic introspection to determine metainformation about the applet. Providing this information enables developers to integrate the Java object into applications more easily.
Finally, for hidden components, those without user interfaces, the JavaScript new
operator provides a way to use components implemented in Java, including JavaBeans, that are described using JavaScript Bean (JSB) files. Creating a JavaScript component using JSB files is described in Creating JavaScript Components. The JSB file structure and the syntax of its tags is described in JSB File Structure Reference.
Using Existing Applets
Most applets written with JDK 1.1 can be used without modification in VJS. You can embed an applet in a VJS page by:
CLASS
file specified in the CODE
attribute of the <APPLET>
tags that appear on the page.
NOTE: If an applet depends on otherAfter import, you can edit theCLASS
or support files that are not directly referenced on the HTML page, these files are not automatically imported. You must repeat the import command for each of these extra files, and you must set the<APPLET>
tag'sFILEREFS
attribute to list these files.FILEREFS
is a quoted string consisting of a comma-delimited list of files. As the applet component is used in applications and deployed, VJS uses the list of files to ensure that the applet's support files are also used and deployed. §
FILEREFS
attribute directly, if necessary. Ordinarily you should not need to edit the attribute, but sometimes, such as when working with graphics files, you may want to change the file list.
CLASS
file into the project. If the applet also depends on other CLASS
or support files, you must repeat the import command for each of these extra files, and you must set the <APPLET>
tag's FILEREFS
attribute to list these files. FILEREFS
is a quoted string consisting of a comma-delimited list of files. As the applet component is used in applications and deployed, VJS uses the list of files to ensure that the applet's support files are also used and deployed.
BeanInfo
class that describes the properties, methods, and events associated with the component. This section of this document explains how to incorporate a JavaBeans component into a VJS project, but it does not describe the actual implementation of a JavaBeans component. The JavaBeans specification can be found at http://splash.javasoft.com/beans. VJS supports JavaBeans components developed with JDK 1.1.
NOTE: Because the most widely used browsers do not fully support JDK 1.1 and AWT 1.1, it's best to develop applications that do not depend on features specific only to JDK 1.1 and AWT 1.1. Instead, build applications to comply with JDK 1.0.2 and AWT 1.0 functionality.A JavaBeans component usually provide a
BeanInfo
to permit inspection. If the BeanInfo
getEventSetDescriptors
, getPropertyDescriptors
, or getMethodDescriptors
methods returns null
, VJS uses automatic introspection to determine this metadata. Reflection is also employed to find set
and get
methods in accordance with the JavaBeans naming conventions if a property descriptor does not provide this information.
NOTE: Web browsers do not support embedding of serialized JavaBeans in a page. Navigator and Communicator, however, do permit placing JavaBeans properties inSome JavaBean components you intend to use as hidden components in VJS may require minor modification to ensure that they do not use JavaScript or JSB reserved words as variable or object names.<PARAM>
tags inside<APPLET>
and<OBJECT>
tags.
<APPLET>
tag with a FILEREFS
attribute referring to all the files in the JAR. This ensures that supporting files are deployed with the component. For explicit directions on importing and installing components, see the VJS Developer's Guide.
NOTE:
After import, you can edit the FILEREFS
attribute directly, if necessary. Ordinarily you
should not need to edit the attribute, but sometimes, such as when working with graphics
files, you may want to change the file list.
BeanInfo
and introspection, which are used to determine the component's properties, events, and methods.
The JSB file that is created defines a script that loads the component at run time; VJS also installs a script icon on the palette for the component. At design time, you can drag the component to a page. If you attempt to view the component's properties, events, and methods in the Inspector, the Inspector displays only the script that is called to load the actual component at run time.
NOTE:
Icon images are not transferred from the JavaBeans component during script creation,
nor is it possible to use a customizer with a hidden component. The help URL, however,
is copied from the BeanInfo
to the JSB, so component help can be displayed from the
palette.
netscape.javascript.adapters.PropertyChangeAdapter
class to access and change Java object properties:
function JavaCursor2_java_beans_PropertyChange(oEvent)
{
if (oEvent.getPropertyName() == "Product")
{
document.JavaDummyCursor2_form._Product.value
= oEvent.getNewValue();
}
...
}
...
JavaDummyCursor2_java_beans_PropertyChange.onChange =
JavaDummyCursor2_java_beans_PropertyChange;
JavaDummyCursor2PropertyChangeAdapter = new
Packages.netscape.javascript.adapters.PropertyChangeAdapter
(JavaDummyCursor2_java_beans_PropertyChange);
JavaDummyCursor2.addPropertyChangeListener(JavaDummyCursor2PropertyChangeAdapter);
NOTE: When you wrap a Java object in a JSB, you should make sure that the attributes of any properties and methods used in the JSB do not duplicate JavaScript and JSB reserved words. For example, do not define a property namedSRC
in the JSB because it will conflict with the<JSB_CONSTRUCTOR>
SRC
attribute.
Row
interface, and the Table
interface. These interfaces use standard JavaBeans conventions. They are designed to work with the JavaBeans PropertyChange
mechanisms. These interfaces define a protocol that is bidirectional, It enables Java and JavaScript components that implement the interfaces to be connected on an HTML page using VJS.
The Row
interface is used to define and transfer a set of name and value pairs, such as one row of a database table. This interface could be used, for example, to connect a cursor object with a form object that displays one row of data at a time. The interface has two parts: one to specify the number of columns, their names and their types; and another to manage the changing and transferring of data.
The Table
interface is used by two components to exchange an entire collection of data. For example, a cursor and a spreadsheet component could use the Table
interface to exchange data.
These interfaces, and various components that implement them (JavaDummyCursor
, JavaForm
, DummyCursor
, TableApplet
and ClientCursor
) are provided as examples in the CDK samples
directory.
NOTE: There are not different interfaces for data providers and data consumers. The same interface is used to send and receive data. This reduces the number of interfaces, adapters and support classes in the system.
Row
and Table
interfaces behave differently depending on their roles. In addition to the sender and receiver roles, each of these interfaces acts in a data context, either as a consumer of data, or a provider of data. Data context refers to the number and names of available columns, the number of rows, the current row, and the numbering of those rows. If two components are connected using the Row
or Table
event, one provides the data context, and the other consumes it.
For example, assume that a cursor is connected to a spreadsheet component, and that the spreadsheet component is also connected to a form component. The cursor is the data-context provider, and the spreadsheet is the data-context consumer. By connecting to the cursor, the spreadsheet inherits its data context, which it in turn provides to the form. Note that the spreadsheet is both a consumer and provider, and that a component's role in terms of data context has nothing to do with the direction of the data transfer.
RowSupport
and TableSupport
are provided as support for the Row
and Table
interface components. These classes make it easy to implement the Row
and Table
interfaces in a JavaBeans component. The classes are similar in nature to JavaBeans adapters, but have slightly different uses.
These classes are generic support classes that are used by the JavaDummyCursor
and JavaForm
examples. Like the PropertyChangeSupport
class in the Bean Developer's Kit (BDK), they can be used as members to which Row
and Table
methods may be delegated. It is also possible to extend these classes, provided, of course, that the JavaBeans does not already extend some other class.
An additional use of these classes is to server as helper objects for JavaScript components. In order to connect to Java objects, the DummyCursor
JavaScript object employs an instance of RowSupport
(created by using the JavaScript new
operator) to hold its current row's data, and to manage the event interactions with Java objects. Without such an object, this a connection would not be possible.
Last Updated: 11/20/97 13:56:35