Getting Started-2-Tier


Lesson 8 . Inheriting from the Repository

The repository provides a development team with a central storage mechanism and access point for commonly used application objects and database-derived widgets. You can easily modify the contents of the repository and propagate changes to all application screens.

In this lesson you learn how to:

  1. If necessary:

Define user input

You can apply an input filter to a widget so it conforms to specific data requirements, such as restricting the length of data or allowing only numeric input. Or, in the case of a telephone number, apply an edit mask so users have a visual cue as to what format is expected when entering data.

  1. Select the phone single line text widget (next to the Phone label) on the distributors repository entry.

  2. Under Input, set the Keystroke Filter property to Edit Mask.

    An Edit Mask subproperty appears, where you define the edit mask.

    In an edit mask, a character that is preceded by a backslash allows a data character to be entered in this position. A character that has no leading backslash is treated as a literal. For example, the string (\9\9\9) specifies to display open and close parentheses around three spaces in which the user can only enter digits, such as (415).

  3. Define the Edit Mask subproperty as (\9\9\9)\9\9\9-\9\9\9\9.

    The widget displays ( ) - and accepts only numbers as input.

More About Input Filters

Panther provides built-in input filters to help guide user input and, at the same time, reduce validation requirements. Some input controls include:

Define what the user sees

You can set properties to enhance specific widgets—for example, using more descriptive label text or using a different font for data entry widgets. The following steps show how to set a variety of properties on different widgets. By setting these properties once in the repository, you ensure that they affect the entire application.

  1. Select the Distrib_name label widget on the distributors repository entry.

  2. Under Identity, change the Label property to Distributor.
  3. Select single line text widget distrib_name.
  4. Under Identity, change the Column Title property to Distributor.

    This property controls the label that appears within the grid widget.

  5. Select label widget Ldistrib_id (Distrib_id).
  6. Under Identity, change the Widget Type property to Dynamic Label.

    Dynamic label widgets have a broader scope of properties; therefore, they are more easily manipulated programmatically (more on this in the next lesson).

  7. Under Geometry, set the Size to Contents property to Yes.

    This property lets the widget resize dynamically according to its label content. If the label changes at runtime, the widget size automatically adjusts. This feature is useful for labels that display a name or date whose length is variable.

Propagate repository changes

Changes made to parent widgets in the repository are visible in child widgets on screens that are open in the editor when the repository entry is saved. To propagate changes to child widgets on other screens, open those screens in the editor, or run the utility binherit to propagate changes as a batch process to all the application's screens.

  1. While the distributors@[Repository] entry has focus, choose FileSave.

    Notice that the mask you added to the phone widget in the repository entry appears in the phone grid member on the dstslect.scr screen. Also, the label next to the query field is updated, as is the column title in the grid widget.

More About Inheritance

When you import a table from a database, the text widgets in the resulting repository entry represent columns in the table. These widgets inherit database-related properties from the database. Like the screen wizard, you can use these widgets to build application screens by copying them from repository entry to screen. The result is an inheritance hierarchy of database to repository to screen (and service component). Also, the next time you use the screen wizard, these changes are implemented.

If changes in the database occur such as length specifications, the changed table can be reimported to the repository. These changes are automatically propagated to all application objects that are copies of those repository objects. Also, any custom attributes that you apply to repository objects, such as color, font specification, and validation, can also be defined and propagated to the screens that inherit from these widgets.

Importation and inheritance simplify application maintenance and facilitate the enforcement of a consistent look and feel to an application's interface.

  1. Choose FileClosedistributors.

    The repository entry closes.

Edit inherited property values

You can modify the behavior established by the screen wizard by writing your own procedure to carry out a particular action. For example, the dstslect.scr screen acts as a search or query screen for finding distributor records, so you might consider using a different screen for adding new distributors to the database. You can change the way the New button behaves through its control string, so it invokes a procedure that opens another screen for adding new records.

More About Control Strings and Control String Syntax

You can attach actions to widgets, menu items, and specific logical keys through control strings. Control strings are a shorthand notation for doing common tasks:

  1. Select the New button on the dstslect.scr screen.

  2. Under Validation, change the Control String property from its inherited property value ^do_new to ^send_dst_data("NEW").

    When the user chooses the New button with this control string, Panther invokes the send_dst_data procedure and supplies NEW as an argument. Lesson 9 describes this procedure.

    The inheritance link no longer exists for this property, as indicated by the absence of reverse-video display.

More About Flexible Inheritance

You can override inherited values on individual properties. For instance, to enforce application standards, all application widgets can inherit colors and fonts from their parent widgets in the repository, but you can also define a font or validation routine for a child widget that differs from its parent. This breaks the inheritance link for the given property.

To reestablish inheritance for a property, select the property and choose the Inh button on the Properties window.

Create a push button widget

Create a push button that executes a procedure to send data from this screen to the dstord.scr screen, which you created in Module 2.

You can create widgets with either the Create menu or the Tool box. The next several steps show how to use the Tool Box.

  1. If the Tool Box is not open:

    UNIX Choose ViewTool Box

    Windows Choose OptionsConfigure Toolbars. Select Create.

  2. Choose CreatePush Button or
  3. Click near the right side of the screen.

    A default-sized push button appears at the cursor position.

  4. With the button selected, under Identity, set its Name property to order_pb.
  5. Set the Label property to Orders.

    The button now has this label:

  6. Set the Default/Cancel property to Default.

    A push button defined as the Default button can be activated at runtime by pressing Enter.

  7. Resize the Order button to match other buttons on the screen:

Define push button behavior

Attach a control string to the push button so it performs the desired action. At run time, the control string executes when the Order button is clicked—in this case, it calls the send_dst_data procedure and supplies an argument of SELECT.

  1. Select the Orders push button.
  2. In the Control String property (under Validation), enter ^send_dst_data("SELECT").
  3. Choose FileSave.

    The dstslect.scr screen is saved to the client.lib library.

Create a buttons repository entry

You can copy commonly used objects from a screen to a repository, thereby providing the entire development team with application objects and code and facilitating consistent behavior and appearance across the application. In this case, you copy the Orders push button from the screen to a repository entry. An inheritance link is automatically established between the object and its parent in the repository.

  1. Choose FileNewRepository Entry.

    The New Repository Entry dialog box opens.

  2. Enter buttons as the name of the entry. Choose OK.

    An empty window with the name buttons@[Repository] opens in the workspace.

  3. Select the order_pb push button on the dstslect.scr screen and drag it to the buttons repository entry.

  4. Return to the dstslect.scr screen and select its order_pb push button again. Check the Inherit From property (under Identity). It is now set to inherit its property values from the buttons repository entry (buttons!order_pb).
  5. Give the buttons repository entry focus and choose FileSave.

    The buttons repository entry is saved to the open repository.

  6. (Optional) Choose FileClosebuttons.

What did you do?

You applied global and local changes to specific widgets, performing these tasks:

What did you learn?

You learned: