Sei sulla pagina 1di 8

Lotus Notes and Domino 6 Programming Bible

by Brian Benz, Rocky Oliver and Richard Schwartz


Wiley Publishing, Inc.. (c) 2003. Copying Prohibited.

Reprinted for Satyendra K. Jha, IBM


satyejha@in.ibm.com

Reprinted with permission as a subscription benefit of Books24x7,


http://www.books24x7.com/

All rights reserved. Reproduction and/or distribution in whole or in part in


electronic,paper or other forms without written permission is prohibited.
i

Table of Contents
Chapter 7: Standard Templates......................................................................................................1
Overview................................................................................................................................1
The Mail Template.................................................................................................................1
The Personal Address Book Template..................................................................................2
The Discussion Template......................................................................................................3
The Document Library Templates..........................................................................................4
Summary................................................................................................................................5
Chapter 7: Standard Templates
Overview
By Richard Schwartz

Notes and Domino provide powerful tools for the development of custom applications. Many Notes
and Domino users, however, are totally unaware of this fact. They know only that their company
uses Notes and Domino for e−mail, calendaring, and address books. Others know only that it
provides e−mail and online discussion facilities. What they don't know is that IBM engineers have
built all the most popular features of Notes and Domino using the same programming tools that are
available to every Notes and Domino programmer for custom applications.

The features of Notes and Domino that end−users know best and that are responsible for much of
the popularity of the products are built from ordinary Notes and Domino templates. Every Notes and
Domino programmer can examine those templates to learn how those features work.

Notes and Domino ship with more than 30 different template files. Many are employed in system
administration tasks and are unfamiliar to most users; others are extremely useful for learning how
to develop your own applications.

This chapter briefly describes the templates that are most familiar to end users: the Mail template,
the Personal Address Book template, the Discussion template, and the Document Library template.

The Mail Template


As the name implies, the Mail template provides all the e−mail functionality of the mail system for
the Notes client. It also provides the calendaring functionality. These two seemingly different areas
of functionality are combined into one NTF file, MAIL6.NTF, to allow tight integration of sending and
receiving invitations, responses to invitations, and the rescheduling of notices for calendar
appointments. The standard Mail template also provides a Web user interface for the mail and
calendar features. Although it's quite powerful, it is not the nicest Web mail interface for Domino. If
you need a powerful Web mail client, check out iNotes Web Access, as it is one of the most
impressive Web clients available.

Note IBM released an alternative Web user interface, known as iNotes Web Access, for
Domino R5. iNotes takes advantage of the advanced features of the latest browser
versions and is therefore able to provide a slicker and more seamless user
interface for mail and calendaring in a browser. The version of iNotes for Domino 6,
however, was not ready to ship at the time that the rest of Notes and Domino 6
were available; however it will be a part of Notes/Domino 6.0.1. Also, IBM wants to
protect its intellectual property investment in iNotes and deliberately obfuscated
some of the code. This book, therefore, can't cover the workings of the iNotes Web
Access template.

The Mail template is, of course, the place to go to find out how to work with e−mail messages in
your applications. Of course, the Mail template has evolved over many years and many releases of
Notes and Domino, and some of the things that you will find in it are not necessarily always done
with the easiest techniques available in Notes and Domino 6. In the Memo form, for example, some
action buttons are used in the Notes client, and duplicate action buttons perform the same
functionality and are used in a Web browser. The Notes client versions are hidden from Web
browsers, and vice versa. This works, but there's a better way of doing this in Notes and Domino 6,
which you find out about in Chapter 16.

Reprinted for ibmsatyejha@in.ibm.com, IBM John Wiley & Sons (US), Wiley Publishing, Inc. (c) 2003, Copying Prohibited
Lotus Notes and Domino 6 Programming Bible 2

The Memo form has many other interesting characteristics. The Send action programmed for the
Notes client uses Notes Formula language to execute @Command([FileCloseWindow]) in
combination with the Present Mail Send Dialog property on that form to cause the message to be
sent. The Send action for the browser is written in JavaScript, and it simply submits the message to
the server, where a WebQuerySave agent called wMemo is invoked. The agent sets the value of
the reserved item MailOptions to 1 to accomplish the same thing. The Memo form uses the
reserved fields SendTo, CopyTo, and BlindCopyTo for addressing. Any form using these same field
names can be addressed and mailed by Notes and Domino.

One of the most interesting parts of the mail template is the Calendaring and Scheduling (C&S)
area. Creating calendars can be tricky if you have never done it before. The Help file is a pretty
good start, but there are more advanced features that you will want to use in your applications —
and most of these are showcased in the C&S area of the mail template. However, you should avoid
the temptation to copy design elements from the mail template and attempt to shoehorn them into
your own application. The C&S area of the Notes 6 mail template is one of the most complicated
features in any Notes application and is comprised of literally dozens of design elements, most of
which would make no sense in an application outside of a mail template. A better approach to
utilizing the mail template in general, and the C&S features specifically, is to examine how certain
features are accomplished. For instance, there are great examples of using the
NotesUIView.RegionDoubleClick (for doing things like composing new documents from the date
that is double−clicked), NotesUIView_.PostEntryResize (for resizing appointment times in the view
and recording it to the underlying document), and much more. There are even two really good
examples of building LotusScript classes to make it easy to handle an otherwise exceedingly
complex task — the CSEventClass and CSUIViewClass, which are housed in LotusScript Libraries
of the same name. Therefore it is recommended that you get inspiration from the C&S feature in the
Notes mail template, but don't try copying it outright from the template itself.

The Personal Address Book Template


The Personal Address Book database enables users to manage personal and business contacts, to
maintain Group documents for mailing lists, and also to maintain some configuration information for
the Notes client. There are several features that are of interest, and fortunately the way the
pernames.ntf template works is easy to understand. These features include the Preferences dialog
box, the Edit Contact Labels button, and the AddressPicker form.

Users can control the display format for contact information using the Personal Address Book
Preferences dialog box, which creates a profile document to store the preference information. Users
can also customize the labels used to identify various fields within each document. The Contact
form, shown in Figure 7−1, makes extensive use of hide−when settings, computed text and
computed for display fields, and a programmable table, which is used to implement a highly
configurable display for users. This form is also a good example of using nested tables to create a
very clean look.

Reprinted for ibmsatyejha@in.ibm.com, IBM John Wiley & Sons (US), Wiley Publishing, Inc. (c) 2003, Copying Prohibited
Lotus Notes and Domino 6 Programming Bible 3

Figure 7−1: The Contact form


The Edit Contact Labels button on the Contact form is an example of the use of the @DialogBox
function in Notes Formula language. If you open the form in Domino Designer and select Preview in
Browser from the Actions menu, you find that this button does not work. The @DialogBox function is
one of several Notes features that doesn't work in browsers. IBM has not Web−enabled the
Personal Address Book application. If they were to do so, they would have to change the code in
this button to use JavaScript instead of using Notes Formula language.

The Personal Address Book template contains the AddressPicker form, which gives users access to
30 buttons, 26 of which are used (in the U.S. English version of the template) for selecting the
letters A through Z for indexing the Contacts list. Although a very straightforward technique could
have been used, it would have been harder to adapt for foreign languages, so IBM engineers
assigned a number to each of the buttons and used it to look up a letter value in a list stored in a
field named AlphList. Modifying this code to work with other alphabets requires only three steps:
changing the contents of the AlphList field, entering the number of letters in the alphabet into the
AlphNumber field, and changing the caption and alternate text properties on each of the button
graphics.

The Discussion Template


Discussion is the archetypal Notes and Domino application. Apart from e−mail, it is probably the
application users associate most with Notes and Domino. The Discussion template, discsw6.ntf, is a
good demonstration of several of the most frequently used Notes and Domino features.

The Discussion template enables Notes clients and browser users to open new topics for discussion
using the Main Topic form, and to participate in threads by adding new documents using the
Response or Response to Response forms. The All Documents view uses Show Response
Documents in a Hierarchy to create an indented display that graphically shows the flow of each
discussion thread (see Figure 7−2).

Reprinted for ibmsatyejha@in.ibm.com, IBM John Wiley & Sons (US), Wiley Publishing, Inc. (c) 2003, Copying Prohibited
Lotus Notes and Domino 6 Programming Bible 4

Figure 7−2: Response hierarchy in the Discussion template


The By Author and By Category views demonstrate categorization, a different organizational
technique. Chapter 9 covers both response hierarchy and categorization. The By Author view also
shows that the Discussion template tracks authorship of documents. An Author Names field is used
for tracking purposes and for security. These fields make it possible to design applications that allow
users to modify only those documents that they have created. Chapter 21 covers Author Names
fields.

Users of Discussion applications can also fill in Personal Profile and Interest Profile forms. An agent
called Send Newsletters, which sends out e−mail messages to users to inform them when new
documents that match the profile are added to the discussion, uses the Interest Profile forms. This
agent is a good example of the use of the NotesNewsletter class in LotusScript.

The Document Library Templates


Notes and Domino also ship with a family of three templates known as the Document Library
templates. The family includes a generic version, along with versions customized for storing
Microsoft Office documents and Lotus SmartSuite documents. The generic version is intended for
use with the Notes client and a Web browser. The Office and SmartSuite versions are intended only
for use with the Notes client. The Office and SmartSuite versions demonstrate the use of Microsoft's
OLE (Object Linking and Embedding) technology, which allows Word, Excel, WordPro, and 1−2−3
documents to appear inside the Notes client window, as shown in Figure 7−3.

Reprinted for ibmsatyejha@in.ibm.com, IBM John Wiley & Sons (US), Wiley Publishing, Inc. (c) 2003, Copying Prohibited
Lotus Notes and Domino 6 Programming Bible 5

Figure 7−3: An OLE 1−2−3 spreadsheet in the SmartSuite Document Library


The most interesting portion of the Document Library templates is the workflow code, which
supports serial and parallel review processes for documents, with facilities for notification of
reviewers and setting time limits for each reviewer. The code that manages the workflow is in the
DocumentWorkflow subform, which uses the OLERoutines script library. The code is fairly well
documented, so you should be able to follow it.

The Document Library templates also support response and response−to−response forms, similar
to the ones in the Discussion template. Although there are no new concepts demonstrated by this, it
shows how easy it is to add a response hierarchy to any Notes and Domino application, adding
value by allowing users to engage in discussions about the data the application manages.

Summary
This chapter examined some of the features of the Mail, Personal Address Book, Discussion, and
Document Library templates. You learned that

• The Mail template demonstrates reserved fields used for addressing mail, form properties
used to send mail from the Notes client, and the MailOptions field used to send mail from a
WebQuerySave agent.

• The Personal Address Book template demonstrates techniques for designing


user−customizable display formats, and is a good example of using tables to control the
visual appearance of data on a form. It also shows techniques for writing generic code that is
easy to extend.

• The Discussion template demonstrates response hierarchy and categorized views. It also
demonstrates the use of Author Names fields to control document security, and use of the
NotesNewsletter class in LotusScript.

Reprinted for ibmsatyejha@in.ibm.com, IBM John Wiley & Sons (US), Wiley Publishing, Inc. (c) 2003, Copying Prohibited
Lotus Notes and Domino 6 Programming Bible 6

• The Document Library templates demonstrate techniques for using OLE to embed Microsoft
Office and Lotus SmartSuite documents within a document in an NSF file. It also
demonstrates techniques for programming serial and parallel workflow processes.

The next part of the book, Part III, dives into the architecture of an application and covers such
topics as pages, forms, views, folders, and so on.

Reprinted for ibmsatyejha@in.ibm.com, IBM John Wiley & Sons (US), Wiley Publishing, Inc. (c) 2003, Copying Prohibited

Potrebbero piacerti anche