Back Forward CDK Home Reference Samples Resources
JSSelect

 Building JavaScript Select family of Crossware Components

The JavaScript Select family of Crossware Components makes use of JavaScript to Java calls, and essentially acts to encapsulate Java functionality for retrieving an URL from a server.


There is a Visual JavaScript PR3 Project File ( (install dir)/samples/JSSelect/JSSelect.prj) which can be opened in Visual JavaScript PR3. One can learn how to use the JSSelect components by inspecting the components on the page once the project is opened, and looking at how the page has been wired together.

Deploy this project (which contains sample Crossware Application pages using the JSSelect components) to a Netscape Enterprise Server.

DBSelect Sample Crossware App

You will need to modify the database pointed to by the DBPool component before this page will work. This assumes you have set up the standard databases on your Enterprise Server.

The DBSelect page illustrates the DBSelect JavaScript component. This component is visible both on the server and on the client, and results in an HTML <SELECT> tag. The component must be placed within an HTML <FORM> tag.

Its properties are server side properties, including the DBPool object which defines the database, a table property for specifying the table, and column names for both the display and value lists. If specified, the "Text Expression" property defines an expression (evaluated in the context of the "cursor" object), which can be uses to customize the display strings of the pick list.

Like the Static Select component, this JSObject can be easily connected to other components (with tools like Visual JavaScript (VJS)), since it publishes its value property as a bound property. In the example below it has been wired to a standard HTML Text field.

To run this example one must manually (or with the help of VJS) copy, compile, and add the resulting Crossware Application to an enterprise server.

StaticSelect Sample Crossware App

This page illustrates the StaticSelect JavaScript Component. This component accepts as properties two coma separated lists: one for the display texts for the pick list and one for their corresponding values. The StaticSelect is visible both on the client and on the server. Its .JSB files uses the "BOTH" value for its "ENV" attribute.

Because this component emits an HTML <SELECT> tag, it must be placed inside an HTML <FORM> tag.

One nice feature of the component is that it exposes (in its JSB) file, a bound property called value, and provides setValue() and getValue() functions. A bound property is one which fires an onChange event when its value changes. Because of this support, it can be easily wired to other standard components, using a tool such as Visual JavaScript. Below are two Static select components, both wired (by Visual JavaScript) together with text fields.

Also specified in its .JSB file is the VISUAL attribute is set to a Java class which draws the component in WYSIWYG page builders, like the one in Visual JavaScript.

To run this example one must manually (or with the help of VJS) copy, compile, and add the resulting Crossware Application to an enterprise server.



( return to the top of the page )