| LDAPBeans

Building the LDAPBeans

There are several LDAPBeans in the netscape/ldap/beans directory. These can all be built using similar methods -- in this example, TableQuery will be used.

TableQuery is built using the BuildTableQuery script (either `BuildTableQuery.sh` or `BuildTableQuery.bat` depending on your platform). This script compiles the necessary classes and uses a manifest file to specify which class is the JavaBean:

`TableQuery.mf`

    Manifest-Version: 1.0

    Name: netscape/ldap/beans/LDAPTableQuery.class
    Java-Bean: True

The TableQuery Bean has an associated BeanInfo class which is used to specify the events that the TableQuery bean can fire. TableQuery is an invisible bean, and although it will appear during design time, it will not appear at runtime. The `TableQuery.jar` that is generated can be imported directly into any tool that supports JavaBeans (like like the BeanBox or Visual JavaScript).

The BeanInfo for TableQuery relies predominantly on introspection, and is used to publish the TableChange and RowChange events. These events make it possible for the TableQuery bean to communicate the results of an LDAP query directly to a component that can listen to Table/Row events (like the CoffeeTable component found on the Visual JavaScript palette).

To create a simple Web Application using the TableQuery component, follow these steps:

- Launch Visual JavaScript:
  - Open a new project
  - Open a new page
  - Open the palette and import the TableQuery.jar file from `CDKINSTALL/samples/LDAPBeans`.
- Drag the TableQuery component that appears to the page.
- Drag a CoffeeTable component (from the palette tab marked "Other").
  - Double-click on the CoffeTable and set the width property to read `90%` (This makes the CoffeTable fill most of the horizontal width of the page)
- Add a textfield and a button.

Now begin wiring the components together:

- Drag the connection point from the LDAPTableQuery to the CoffeeTable
  - Select the tableChange event
  - Apply the changes
- Drag the connection point from the TextField to the LDAPTableQuery
  - Select the onBlur Source event
  - Press the Script Builder button:
  - Select the setFilter method
  - Add the action, and replace the text within the parenthesis that appears in the script handler portion of the window with the text `"cn="+this.value`
  - Apply the connection.
- Drag the connection point from the button to the LDAPTableQuery.
- Bring up the ScriptBuilder, and create an onClick script handler which calls the method executeQuery() by simply double-clicking on the "executeQuery()" entry from the list in the "Call Method" tab.
- Apply this connection.

Now all that is left to do is to double-click on the LDAPTableQuery component and set its properties in a manner appropriate for your network.Contact your systems administrator for details, or take a peek at the sample values in the screen snapshot of the running sample shown below:

Important Note: When you are done setting the parameters for the TableQuery component, deploy the application to your webserver to see your results. Previewing LDAP-based Web Applications is not supported in this release, using Preview may cause your browser to become uncommunicative for unusually long periods of time.

Congratulations! You've just built your first LDAP-enabled Web Application!

( return to the top of the page )