JavaScript Libraries in Domino

New to Designer 6, there is finally a place to store JavaScript script libraries inside the database as a shared resource. If you have a Web application that uses a large number of JavaScript functions, you can easily create a library document to store each function; this can then be easily accessed and shared by all objects in your database. Using libraries is much easier to manage than copying various functions to and from each form that requires it.

You can use (call) a JavaScript library from inside Domino Designer in several ways. For instance, you can place the .js file on the server in one of the notesdatadomino directories, attach a file to a document and access it from a view, add the inline script directly to a subform, and include the subform on the form. However, the most effective way ”and new to Designer 6 ”is to add it to the database as a script library in the shared code section of the Design pane.

The first option is certainly not very flexible, and the developer needs physical access to the Domino server to place the file in a directory. If your server is secured inside a room onsite, or even off-site on the other side of the world, and only certain employees have access to it, this method is obviously not practical. The second option offers flexibility without the first method's hassle. This method uses a view, a document, a .js file attached to a document, and a keyword to find the document containing the file. Developers used this method in previous versions of Domino to access SRC content for Web pages before script libraries had their own place. The following is the command line to call a script library from within the JS Header using the second method:


Table 16.4 shows the parts that make up this example:

Table 16.4. JavaScript Syntax to Call a JavaScript Library via $FILE

SRC Used inside tags or within the JS Header . Specifies the name of the file to locate the script statements. When scripts are not written inline, SRC informs the browser where the script file can be found.
DbName The name of the current database.
JSLibView The name of the view where the document is collected.
Library The keyword used to find the document in the view.
$file Instruction for Domino to get the attached file on the document.
module1.js The name of the JavaScript library.

As you can see, this approach is much easier and flexible than placing the files on a server that the developer can't always access.

The command line for accessing a file in a notes/data/domino/JSLibs directory would be this:


However, the new Designer 6 design features make this task even easier. Add the JavaScript script library to the database as a shared resource. Once added, it can be accessed in the JS Header event as a shared resource, as shown in Figure 16.8.

Figure 16.8. Including a JavaScript script library shared resource in the JS Header event of a form.


To call a script library, simply place your cursor inside the JS Header event and then, from the menu bar, select Create, Resource, Insert Resource. The Insert Resource dialog box displays, showing the available script libraries from which to choose. Select the desired library and click OK. The JS Header event shows the script placeholder icon that indicates that the script library has been added to the event (see Figure 16.9).

Figure 16.9. Using a JavaScript script library shared resource in the JS Header event of a form.


Part I. Introduction to Release 6

Whats New in Release 6?

The Release 6 Object Store

The Integrated Development Environment

Part II. Foundations of Application Design

Forms Design

Advanced Form Design

Designing Views

Using Shared Resources in Domino Applications

Using the Page Designer

Creating Outlines

Adding Framesets to Domino Applications

Automating Your Application with Agents

Part III. Programming Domino Applications

Using the Formula Language

Real-World Examples Using the Formula Language

Writing LotusScript for Domino Applications

Real-World LotusScript Examples

Writing JavaScript for Domino Applications

Real-World JavaScript Examples

Writing Java for Domino Applications

Real-World Java Examples

Enhancing Domino Applications for the Web

Part IV. Advanced Design Topics

Accessing Data with XML

Accessing Data with DECS and DCRs

Security and Domino Applications

Creating Workflow Applications

Analyzing Domino Applications

Part V. Appendices

Appendix A. HTML Reference

Appendix B. Domino URL Reference

Lotus Notes and Domino 6 Development
Lotus Notes and Domino 6 Development (2nd Edition)
ISBN: 0672325020
EAN: 2147483647
Year: 2005
Pages: 288 © 2008-2020.
If you may any questions please contact us: