Creating Reusable Design Objects

One fundamental goal of object-oriented programming is to create reusable design elements. Perhaps the single most compelling reason for creating reusable elements is that after the object or reusable element is designed, debugged , and working well, it can be inserted wherever it's neededwithout worrying whether it will work or having to rewrite it. This saves a tremendous amount of time, as I'm sure you can imagine. Before Release 4 of Notes, there was only a single reusable design object: the shared field. Release 4 introduced subforms and script libraries. R5 introduced shared actions, image resources, and applets. Designer 6 added Cascading Style Sheets, files, and Data Connection Resources (DCRs). All the shared design elements are now collected in the Shared Code and Shared Resources categories in the Design list.

Creating and Using Subforms

Subforms are designed exactly like forms and can contain text, fields, graphics, layout regions , buttons , actions, and so on. Subforms contain common data elements, actions, and scripts. Deciding what data items are candidates for subforms can be done by following good design principles and by comparing the data items among all the forms.

When comparing the data items, look for repeating elements. The rule of thumb to use when determining whether a subform should be created is this: Will this group of fields, actions, and so on be used in more than one form? If the answer is yes, a subform should be created. If the subform will be used in more than one database, it gets added to a design library.

Subforms can also be used to present data on the same document to different users in a different manner. You can do this by conditionally inserting the subform.

A subform is designed exactly like a form. To create a new subform, open the Shared Code category in the Design list, and click Subforms. Click the New Subform button. Figure 5.46 shows a subform in design that can be used to provide a common header for all forms in a database.

Figure 5.46. A subform can be used to provide a common appearance to all forms in a database.

graphics/05fig46.jpg

The Subform properties box shown in Figure 5.46 has two tabs, the Subform Info tab and the Security tab. On the Info tab, you name the subform and add a comment, if appropriate. Because there is no alias field, add one by using the pipe symbol ( ) after the name of the subform, followed by the alias of the subform. Two check boxes at the bottom of the tab determine how the subform can be inserted: Include in Insert Subform Dialog and Include in New Form Dialog. If the latter is checked, whenever a new form is created, a dialog box opens displaying any subform with that property. The last two check boxes on the Info tab are Render Pass-thru HTML in Notes and Do Not Add Field Names to Index.

If subforms are present in the database, when you create a new form, you are automatically prompted to insert a subform. You can also insert subforms at design time by choosing Create, Insert Subform from the menu. The Insert Subform dialog box displays with a list of available subforms (see Figure 5.47).

Figure 5.47. The Insert Subform dialog box allows you to choose a subform or to insert a subform based on a formula.

graphics/05fig47.jpg

Subforms can also be inserted based on a formula. In that case, check the Insert Subform Based on Formula check box in the Insert Subform dialog box. The formula must evaluate to the name or alias of a subform.

Using Shared Fields

Shared fields are stored in the Resources, Shared Field Design list. Only the field definition is shared, not the data. To create a shared field, follow these steps:

  1. Open the Shared Field Design list.
  2. Click the New Shared Field button, or click the Create Shared Field SmartIcon.
  3. Give the field a name, and set the remaining properties, as appropriate.

TIP

A single-use field can be converted to a shared field by selecting the field and choosing Design, Share This Field from the menu. Alternatively, a shared field can be converted to a single-use field by choosing Design, Convert to Single Use.

 

Shared fields can be added to forms and subforms by clicking the Insert Shared Field toolbar icon or by choosing Create, Insert Shared Field from the menu. A dialog box similar to the Insert Subform dialog box appears, displaying the available shared fields.

To edit a shared field, go to the Shared Fields Design list and double-click the shared field entry. Figure 5.48 shows the Shared Field design window that occupies the entire design area.

Figure 5.48. A shared field in the design window is showing the Design pane and the properties box.

graphics/05fig48.jpg

Shared fields can be quickly identified on a form by the double-thick border around the field name.

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

show all menu



Lotus Notes and Domino 6 Development
Lotus Notes and Domino 6 Development (2nd Edition)
ISBN: 0672325020
EAN: 2147483647
Year: 2005
Pages: 288
Similar book on Amazon

Flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net