Getting Started-2-Tier


Lesson 6 . Setting Properties to Query the Database

In this lesson, you enhance the Distributor Orders (dstord.scr) screen so users can query the database for a specific distributor record. You learn about Panther widget properties and how to set them.

Properties can be set and changed locally for the current screen and its components, and globally for objects throughout the application:

In this lesson, you set properties that let users search the database for a specific distributor by entering an identification number. The transaction manager automatically generates the appropriate SQL query statement based on this input, submits the input to the database engine, and returns the desired distributor data to the client.

In this lesson you learn how to:

  1. If necessary:

Use the Properties window

You can define the appearance and behavior of screens and widgets through the Properties window. If the Properties window is not open in the editor workspace, open it with one of these actions:

More About the Properties Window

The Properties window lets you easily view and set properties for all Panther objects—for one object at a time or for multiple objects simultaneously. If multiple objects are selected, the Properties window displays those properties that are common to all, so you can assign the same font, colors, and formats. If the selected objects have different values for a given property, three question marks (???) are displayed as the property value.

When no widgets are selected, the Properties window displays the properties of the current screen.

Properties are grouped by category under descriptive headings on the left. Initially, the properties list is collapsed and displays only headings.

  1. In the Properties window, choose .

    All property headings expand, displaying the properties and their respective values on the right. To change a property value, select the property and type or select a new value in the Setting field/option menu of the Properties window.

    You can also expand and collapse headings individually. To expand or collapse a single heading, simply click it.

  2. Choose .

    The properties list collapses, displaying only the property headings.

No matter how you set a property, you can reverse any change with EditUndo or .

Change properties

The next several steps show how to set a property on a widget located on the screen level. You need to set a Database property for the distrib_id widget so that users can obtain information about a specific distributor and its orders via its ID number. The ID number is used to search for a matching record in the database.

  1. On the screen dstord.scr, select the single line text (data entry) widget distrib_id, which is adjacent to the Distrib_id label.

  2. In the Properties window, select the Database heading.

    Database-specific properties are displayed.

  3. Under the Database heading, select Fetch Data. Fetch-specific properties are displayed.

  4. Select the Use In Where property.

    An option menu is made available in the Properties window. Here you select from a list of predefined values.

More About Setting Predefined Property Values

You can set a property with predefined values in several ways after you select it:

  1. Click on the option menu to display its drop-down list, and select Yes. Press Enter or choose OK.

    Yes tells Panther to use the field in the WHERE clause of the database query. When you change the Use In Where property to Yes, two other changes occur:

Database property settings give Panther's transaction manager the information it needs to build an SQL statement to fetch, display, and update the requested record. At runtime now, when a distributor ID is entered in the distrib_id widget and a View or Select command is issued, Panther searches the distrib_id column in the distributors database table for a record with a matching ID.

More About Inherited Property Values

The Properties window uses reverse video to show which property settings are inherited. The Inherit From property under the Identity heading identifies the source of inheritance. Objects within the repository that are imported directly from a database have their Inherit From property set to @DATABASE.

Screens that are created by the screen wizard inherit screen, push button, and grid property values from prototype wizard-specific repository entries, while labels and data entry-type widgets inherit their property values from database-derived repository entries.

Save the screen

In order to view your changes in the browser, you must first save the screen.

  1. With focus on the dstord.scr screen, choose FileSave or .

    The screen is saved to client.lib.

View specific records

Now test the screen to find a specific distributor's records.

  1. If the dstord.scr screen still displays inside your browser, reload it. Otherwise, invoke the screen by supplying this URL:
    http://hostname/cgi-bin/webAppname/dstord.scr

    You can also choose FileTest Mode to view the screen in GUI.

    The Distributor Orders screen displays.

  2. Enter 3 in the distrib_id field.
  3. Choose .

    The distributor record for Videos Tonight displays.

    Now, modify the phone number.

  4. Choose .

    Your changes are written to the database.

  5. Choose .

    The transaction closes. You can try all the buttons on the screen. After each transaction, remember to choose Reset to close and clear the fields.

    Note: Using the Delete button on this particular screen deletes the selected distributor and its orders. However, this also orphans records in the order_items table that are associated with the deleted orders records. Therefore, do not delete distributors via the dstord.scr screen.

  6. Close the browser window or press Shift+F5 (Esc twice or choose OptionsEditor) to exit GUI test mode and return to the editor.

What did you do?

In this lesson, you created a query screen that lets a user enter data that is used to search for a specific database record. You did this by performing these tasks:

What did you learn?

You learned: