Previous | Table of Contents | Next

Page 499

You can reinherit a property or method that you have overridden by selecting the property (or method) and pressing the Reinherit button at the top of the property sheet (it is two buttons to the right of the + button). When you do this, the property (or method) will revert to its inherited value, and the diamond will revert from black to gray.

Overriding an Inherited Class Method

As an object-oriented programming environment, Power Objects allows you to override a method that has been inherited. You can see how this is accomplished by referring to MyForm and MyFirstClass. As you recall, MyFirstClass contains a pushbutton named btnClose, which has method code specified for the Click method.

When you added an instance of MyFirstClass to MyForm, that class instance inherited the Click method code. Let's see how you can override the processing that was specified in btnClose.

  1. Open MyForm by double-clicking its icon on the Main Window.
  2. Select btnClose, and right-click Property Sheet.
  3. Scroll down to the Click method, and enter a single line:
    MSGBOX("Override the Click method")
    
  4. Click on the method title. Notice that the method is a solid black triangle, indicating that it overrides its inherited method code.
  5. Close the property sheet and test MyForm. When you click on Close, a message box appears informing you that the Click method has been overridden (see Figure 18.16).
  6. When you click OK in the message box, nothing else happens. As you would expect, the inherited method code does not execute.

Figure 18.16.
Testing the overridden
method.

Page 500

Power Objects will also permit you to override the method code and invoke the inherited method code. The statement Inherited.Method_name() is used to execute the default processing for a method. Using the example of MyForm and MyFirstClass, suppose that you have decided that you want to display a message box when Close is clicked but also want the inherited method code to execute. To achieve this, select btnClose on MyForm, and right-click Property Sheet. Scroll down to the Click method, and enter these two lines of Oracle Basic:

MSGBOX("Override the Click method")
Inherited.Click()

The first line will display a message box containing the specified message. The second line will invoke the method code for btnClose that specified in the class, MyFirstClass. Exit the property sheet, and test the form. When you click on Close, the message box displays the message about overriding the Click method. When you click OK, another message box appears, demonstrating that the inherited code is executing.

As you learn more about the use of classes and inheritance, you'll discover that you'll benefit from their use in several ways:

Building an Oracle Power Objects Report

The last object you're going to explore in Power Objects is the report object. An application can contain zero or more reports. To add a report to an application, open the Main Window, select the application in which you want to create the report, and press the New Report button on the toolbar. As an alternative, you can select Object | New Report from the menu. A window will appear, containing the new report. If you look at the Main Window, you will see that the new report belongs to the application (see Figure 18.17).

Page 501

Figure 18.17.
New report object
belongs to application.

Sections of a Report

If you maximize the window that contains the new report, you will see that the report contains five sections (see Figure 18.18):

ReportHeader The objects that you place in this area will be displayed once, at the beginning of the report.
PageHeader The objects that you place in this band will be displayed at the top of each page.
Detail This band contains the objects that constitute the body of the report. These objects are repeated once for each record retrieved by the report.
PageFooter The objects that you place in this band will be displayed at the bottom of each page.
ReportFooter The objects that you place in this band will be displayed once, at the end of the report.

Increase the width of the report by dragging the right edge of the report to the right.

Page 502

Figure 18.18.
New report layout.

Specifying Report Objects

Let's set some properties for the new report:

  1. From the report window, right-click Property Sheet, and specify these properties:
        Label            Course Catalog
    
        Name             rptCourseCatalog
    
        RecordSource     Course
    
        RecSrcSession    Flugle (this is the database session to be used by the report)
    
  2. Exit the property sheet.
  3. Let's add a group section to the report. On the Object Palette, click on the Report Section button (it resembles a page containing red rectangles), and click in the Detail band on the report. You'll notice that the report now has two additional bands: a GroupHeader band and a GroupFooter band (see Figure 18.19).

Page 503

Figure 18.19.
Group header and
footer bands added to
report layout.

Specifying the PageHeader Area

The objects in the PageHeader area will be printed at the top of each report page. Therefore, this is where you want to specify the report title and any other information you want to appear on every report page. Select the PageHeader by clicking on the dark gray band and right-click Property Sheet. By default, the PageHeader has a property named FirstPgHdr that is set to False, causing the objects in the PageHeader to be suppressed for the first page. Set this property to True, and close the property sheet. As shown in Figure 18.20, add a title and subtitle for the report. Click the Static Text button on the Object Palette, and click in the PageHeader where you want the title to appear. You will see a highlighted field labeled static1; enter the title that you want to appear on the report. Follow the same steps to add the subtitle.

Previous | Table of Contents | Next

Используются технологии uCoz