Progress
ADM 2 Guide
Creating the myviewer Class
The example in this section illustrates creating a new class based on the viewer class. The new class, called myviewer, will contain custom functionality that displays a warning message to an application user who wants to delete a record and allows the user to choose how to proceed. This functionality will be built into all SmartObjects based on this class.
The following sections describe how to create the new myviewer class files, then modify them to create the new functionality.
NOTE: The example assumes that you installed Progress in theD:\PROGRESS
directory.Creating the myviewer Class Files
Follow these steps to create the myviewer class files:
- From the AppBuilder main menu, choose the Tools
New ADM Class... command:
![]()
The New ADM Class dialog box opens, with the Basic tab in front.
- Type myviewer, the new class name, in the Name field:
![]()
Note that when you type myviewer, the AppBuilder enters default directories in the directory fill-in fields and names based on myviewer in many of the filename fill-in fields; for example,
myviprop.i
for the property filename.- Select the class from which to derive the myviewer class:
- Click on the Class button next to the Derive From Class field. In the Choose Class Definition dialog box that appears, you are placed by default in the
%DLC%\src\adm2
directory.- Select the
viewer.cld
class definition file in that directory, then choose Open.The AppBuilder adds information to the New ADM Class dialog box:
![]()
Note that the Derive From Class field now contains the
viewer.cld
class definition file. Note also that the Copy From Template field is automatically filled with the filename of the viewer template. This happens only because the class definition file contains a definition of this template; if it did not, this field would stay empty.- Click the Custom Files tab to note the custom class files that will be generated for the myviewer class:
![]()
- Click the Basic tab, then click to check the Open files in the AppBuilder once generated check box at the bottom of this tab. This instructs the AppBuilder to open the primary include file, the property file, the super procedure file, and the prototype file after creating the class files:
![]()
- Press OK to create the files.
- After the AppBuilder finishes creating the myviewer class files, close the primary include file (
myviewer.i
) and the prototype file (myviprto.i
); these files do not need modification in this example.Modifying the myviewer Standard Class Files
You use the following new code to implement the custom myviewer functionality: a DeleteMessage property, a setDeleteMessage function, and an override procedure for the standard ADM deleteRecord method. Adding this functionality requires changes only to the
myviprop.i
property file and themyviewer.p
super procedure file, both of which should still be open in the AppBuilder.Follow these steps in the AppBuilder to add the new functionality:
- Define the new DeleteMessage property in the
myviprop.i
property file. To do this, go to the file’s main block and add the code shown in bold typeface:
When you finish making these changes, click on the Save button (the diskette icon) on the AppBuilder main window to save your changes, then close the property file window.
- Create a new setDeleteMessage function in the
myviewer.p
super procedure file. This function allows you to set the new DeleteMessage property. To create the new function, add the code shown in bold typeface:
- Create a new override procedure for the deleteRecord method in the
myviewer.p
super procedure file. This procedure displays an alert box when the deleteRecord method is invoked; this alert box prompts the user with a message that corresponds to the value of the new DeleteMessage property: if the user chooses Yes, the ADM deleteRecord executes, otherwise it returns without executing. To create the new override procedure, add the code shown in bold typeface:
When you finish making the changes in Steps 2 and 3, click on the Save button (the diskette icon) on the AppBuilder main window to save your changes, then close the super procedure file window. The AppBuilder now creates a
.r
version of the super procedure in thesrc\adm2
directory under your working directory.NOTE: If you do not move the- Enable the new super procedure file by moving the
.r
file from thesrc\adm2
directory under your working directory into theadm
2 directory under your working directory..r
file into theadm
2 directory under your working directory, you will not be able to use the new super procedure.- Make the template for the myviewer class available on the New dialog box that appears when you choose File
New from the AppBuilder menu. To do this:
The new class, with its custom behavior, is now ready for use. Before you work with it, you should restart the AppBuilder to re-establish the super procedure stack.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |