Oracle Forms Version 5.0: Templates and Object Libraries - Now That We Have Them, What Do We Do With Them?

Peter Koletzke

A & Z Software Co., Inc.

Dr. Paul Dorsey

Dulcian, Inc.

Overview

Forms 5.0 presents us with a lot of added functionality designed to increase developer productivity. This paper will focus on two of what we believe to be the most important new features of Forms 5.0. When used effectively, these features can greatly decrease the time needed to develop production-level applications.

In less time than it used to take to build non-functioning screen shot prototypes, you can now build production level functioning applications!

Using templates and object libraries differ from other features of Forms 5.0 in that they require an established development infrastructure, specifically GUI standards and coding standards. It is important to prepare for development. For those of us who have been using Forms 4.5, developing an appropriate template and figuring out what sort of objects might be built to go into the libraries might be intuitive. However, if you are new to the product, it will be very difficult to intelligently build a template or objects for your object library until you have built a few applications. By effectively using Forms 5.0’s templates and the object library, you can achieve an order of magnitude improvement in development speed.

How much of a benefit can we expect with these new features? If you have been building forms with version 4.5 for some time, you will notice that your forms all tend to have the same sorts of elements in them. Selection lists are built in a certain way. Master detail relationships will also be handled similarly. Each developer will have his or her own style; but most of the development time is spent making these style decisions. You have probably noticed that after building a few applications, when you want to build a form similar to another you’ve already built (except against a different set of tables), you’ll find that forms can be built more easily using those basic elements. The trick is to identify and genericize those common elements and make them available in a template or object library where they can be easily reused for multiple developers across all applications.

A specific example of how you can decrease development time using templates and object libraries involves one of the most complex forms we have built. It consists of a flexible reporting front-end which allows users to dynamically select sorts, breaks and filters which are them passed to the reports using lexical parameters. The first time we built this form, the one form required several developer months of effort. Even when we subsequently built a similar form for a different application, it took several weeks. However, we genericized the form down to its component parts and placed those objects in an object library (implemented by a form in Forms 4.5). We also genericized all of the code and placed it into a Forms 4.5 PL/SQL library. Now, that same flexible reporting front-end can be built for a new application in less than one day. The moral of the story is to take the time initially to follow this three step process:

1.       Identify the types of applications that can be used over and over.

2.       Identify the common components in those applications.

3.       Build generic versions of those components that can be quickly assembled and modified in a new application.

Using this method, when building a new form, you can decrease your development time for a full application from weeks to days. Your application will not only have a consistent look and feel, but will also be virtually bug-free due to the use of well-tested components.

Making efficient use of templates and object libraries in Forms 5.0 can fundamentally change your development method. Prior to Forms 5.0, we were able to prototype applications very quickly that were either simple screen shot storyboards or were limited to the functionality that could be generated by Designer/2000. But it was still difficult to adopt a rapid applications prototyping development method because we couldn’t develop applications all that rapidly. Using templates and object libraries, a full set of modules for a 10-20 table application can be built in a week.

 

Templates

Templates are a new feature in Forms 5.0. A template is nothing more than a partially built form. Note: As of this writing, the only way to apply a template to a form in Forms 5.0 is when you open Forms Builder and specify “Build a form based on an existing template” in the dialog box. What do templates buy you?  Quite a lot, actually. In your template, you can set sizes and properties for Windows and canvases, have your standard attached libraries, basic triggers built on the template, and, in general set up the templates so that as applications are built, everything you might need is at your fingertips. This includes sample toolbars, menus, property classes, referenced objects or anything else you might want in your form. There are no special template files. A template in Forms 5.0 is nothing more than a standard .fmb file. Applying a templat is exactly the same as opening your template form and doing a “File/Save As” to copy the template name and begin developing. There is no explicit inheritance from a template. However, the template iteslf may contain referenced objects. Therefore, when the template is applied, it will contain those objects referenced in the same way. Be aware that once the template is applied, there is no longer any link between the form and the template.

We liberally used templates in Forms 4.5. Much of what we includedin the template can now be more efficiently handled by placing those objects in the Object Library. Therefore, templates will actually have much less in them than before. The template will include attached libraries with generic PL/SQL code including triggers for initialization of the form, generic toolbars, etc. A sample small template and Object Library can be downloaded from one of the authors’ Websites at: XXXXXX. Specifically, as in the past, there will be no property classes in the template. All functionality supported by property classes in 4.5 will be supplanted by smart classes (discussed below) in the Object Library in Version 5.0.

 

Object Libraries

The object library can act as a repository for two different kinds of structures. First, it can act as a repository of items just like an fmb file. The advantage to storing items in an object library instead of an fmb is that they can be displayed in a more convenient multi-tab interface. The other type of information that can be stored in an object library is an item archetype. Item archetypes can be used as property classes were used in Forms 4.5. The kind of objects that properly go into the Object Library should be thought through very carefully. The idea is to provide developers with structures that greatly decrease their development time. The example discussed below was fully generic and required the developers do no more than wirte a few lines of code. However, you can also place structures into the Object Library are nothing more than examples of solutions to complex problems that may require extensive modification by the developers. Even complex graphics objects can be stored in the Object Library, for example, elegant address book applications or other graphics objects.

 

Storing Objects in the Object Library

An example of a specific object that can go into the object library is a multi-select LOV, one of the most commonly requested features missing from Oracle Forms. A multi-select LOV is an LOV where the user can select multiple items from a list in their application, for example, selecting multiple inventory items for a purchase order or multiple people from a list of employees for membership on a committee. Currently, with Forms 5.0, the only way to support this feature is through a substantial amount of coding. However, it is possible using Forms 5.0 to build this object in such a way that developers can take advantage of this powerful feature while only writing a small amount of code. The trick is to think through the process of the multi-select LOV, write the code and build the appropriate objects so that this feature can be created very quickly. The multi-select LOV is comprised of an object group and a library. Therefore, to use a multi-select LOV, you have to bring in the object group and attach the library. The object group is composed of a canvas, a block and several iconic buttons with their associated triggers.

The library contains two packages:

1.       Functions needed for the developer to use the LOV

2.       Functions and procedures used internally within the multi-LOV

From the developer’s perspective, after bringing the appropriate objects into the application, what they have done is effectively extend Forms to support multi-LOVs using only two lines of code. To create the multi-LOV, the developer need only write a single line of code: MLOV.CREATE.

It takes as parameters a two-column record group and the name of the LOV. Wherever the multi-LOV is supposed to appear, MLOV.INVOKE, passing it merely the name of the LOV and the return value is a comma delimited list of values. As of this writing, we would have liked to have made the return value a PL/SQL table, but that functionality was not yet implemented in the product.

Behind the scenes, the multi-LOV populates a record group and then populates a generic multi-LOV block with the data. When users are selecting items on the block, the multi-LOV simulaneously keeps track of the selected records in the record group. Then, when the user clicks on the OK button, the record group is scanned and the selected records are extracted. There is quite a lot of planning, code and several days of development time required to build this structure but its usefulness in many applications will quickly offset the investment in development effort. To list the entire system documentation for the multi-LOV is beyond the scope of this paper. However, the following is an example of the code behind the invoke procedure.

Invoke

Display the Multi LOV dialog box.

 

Code

Comments

Multi_Lov_Lib.Name_Triggerx := Par_Trigger_Name;

If the user wants to execute code when this is finished, store the trigger name they want to fire in the global variable.

execute_trigger('Multi_LOV');

Store system information into global variables

multi_lov_lib.lov_name := par_rg_name;

  multi_lov.name_of_item := Multi_Lov_Lib.Item_Cursor;  ---so we will know where to send the cursor back to

   multi_lov.drop_out := par_out_drop;  -----where to send the final list

Set up the Record Group, Return Item, and destination globals.

IF  par_recreate_group = 'Y'

  THEN

      my_group_counter := Get_Group_Row_Count('my_group');

      FOR i IN 1 .. my_group_counter

      LOOP

          var_rg_name := Get_Group_Char_Cell('my_group.col1',i);

          IF var_rg_name = par_rg_name

          THEN

               var_query := Get_Group_Char_Cell('my_group.col2',i);

          END IF;

      END LOOP;

      Delete_Group( par_rg_name );

      multi_lov_lib.CREATE_RG ( par_rg_name,var_query );

  END IF;

If the user wants to recreate the record group, then delete the old group and re-create it.

col_name  := Get_Group_Char_Cell( par_rg_name||'A.col1', 1 );

  data_type := Get_Group_Char_Cell( par_rg_name||'A.col2', 1 );

Get the datatype of the columns

gc_id     := Find_Column(par_rg_name||'.'||col_name  ); 

  Show_Window('MULTI_LOV',par_x_pos,par_y_pos);

  go_block('multi_lov');

Show the Multi LOV window

clear_block;

  the_rowcount := Get_Group_Row_Count(par_rg_name);

  FOR i IN 1 .. the_rowcount

  LOOP

     multi_lov_lib.DOUBLE_CLICK (par_rg_name);

     IF data_type = 'NUMBER'

     THEN

        temp := Get_Group_Number_Cell(par_rg_name||'.'||col_name,I);

        copy(to_char(temp),'value_item');

     ELSIF data_type IN ('VARCHAR2','CHAR')

     THEN

        copy(Get_Group_Char_Cell(par_rg_name||'.'||col_name,I),'value_item');

     ELSE

          copy(To_Char(Get_Group_Date_Cell(par_rg_name||'.'||col_name,I)),'value_item');

     END IF;

      IF i <> the_rowcount

      THEN

          Next_Record;

      END IF;

  END LOOP;

Use the proper Get Group Cell function for the datatype.  Covert the value to character and place it in our Multi LOV block.

 

 

 

One of the problems with the “Invoke Multi-LOV” package is that the code following the invoke function would be executed immediately because all that “invoke” does is make the multi-LOV appear. There is no way in Forms to suspend the action of a PL/SQL block; but we wanted to provide developers with the ability to execute code after the user clicked on the OK button. Therefore, one of the parameters in the invoke function is to execute a named trigger after the user clicks on the OK button. This is an example of the kinds of things that can be stored in the Object Library.

 

Storing Item Archetypes in the Object Library

The other types of objects that go into the Object Library are item archetypes.

You can create an archetypal button of a specific height and width with a default trigger. Then, every time you wish to create a button, you can simply create an instantiation of your archetypal button and make modifications. The way this is done is as follows:

1.       Create the archetypal button.

2.       Drag the button from the Object Navigator into the Object Library.

3.       Whenever a button is needed, drag the button from the Object Library, thus creating an instantiation of that button.

This method is applicable to other objects in the Object Library.

 

Smart Classes

When dealing with archetypal objects, there is an even easier way to create the instantiations. This is the notion of “Smart Classes.” Smart Classes enable you to choose from a subset of the archetypal objects in the Object Library without even having to have the Object Library visible on the screen. To do this:

1.       Specify an object in the Object Library as a smart class by selecting the object in the Object Navigator.

2.        Choose “Smart class” from the Object Menu. This places a green checkmark next to the selected object in the Object Library.

·         Note: Before objects in the Object Library can be used, the Object Library must be saved.

3.       Right click on the item in the Layout Editor or in the Object Navigator. Select Smart class from the pop-up menu and you will see a list of the names of all items from all open object libraries. However, only those of the same item typs as the object selected will be displayed. Thus, if you have selected a button, you will only see smart classes associated with buttons.

This method provides developers with an excellent vehicle for quickly and easily applying consistent GUI standards. We can do more than merely set simple properties. Using buttons as an example, we can create sample EXIT, QUERY and specialized iconic toolbar buttons along with their associated triggers and store them all in the Object Library. Once you have built an initial set of generic buttons, you can very quickly build customized toolbars and support whatever button functionality you choose for you application.

 

Of course, smart classes need not only be created for buttons. They can be applied to items of any type. You can have smart classes for canvases and window to easily support different screen resolutions. You can easily enforce GUI standards through creating smart classes for items. One serious decision to be made is how you want to set text item widths in your applications. With proportional fonts, it is quite difficult to intelligently set item widths. Given the way that smart classes only restrict by item type, it is impractical to have a different smart class for every item width. If you tried to have a different smart class for every conceivable item width for every conceivable item type, this would require several hundred smart classes and be completely impractical to use. Your list of smart classes would be too large to be usefu. Therefore, we recommend that you determine the apppropriate field width. Write down this information as part of your standards and set field widths manually rather than enforcing them through smart classes. Another alternative for setting item widths would be to write a C++ program using the new Forms API which would automatically set item widths for each text item based upon a lookup table. A complete discussion of this is beyond the scope of this paper. However, we do recommend that you apply smart classes of specific widths for at least some frequently used small code fields such as Boolean T/F and gender M/F fields.

 

Referenced Objects in 4.5 vs. Subclassing in 5.0

The way referenced objects work is that only fields that are explicitly set in the  parent object are referenced. The behavior of referenced objects, (now called subclassed objects in version 5.0) has fundamentally changed making them vastly more useful and rendering the notion of property classes obsolete. Property classes are nothing more than a list of properties that can act as a list from which other objects can inherit properties. The problem with property classes is that they need not correspond to any particular object. This grants a flexibility to the developer to create property classes that are not rational. The reason we had properclasses was because of the limited implementation model for referenced objects in version 4.5. In Forms 4.5, a referenced object was essentially a copy of all properties from an existing object. Furthermore, none of those properties could be changed. In 5.0, the concept of a referenced object has been replaced with the much richer concept of subclassing. In subclassing, an object inherits only properties in the parent object which are different from the default properties. This allows you to select the subset of properties in the parent object that you want the child object to inherit. In the child object, you have the ability to override the interited properties.

 

Supporting Different Kinds of Applications

Modules tend to fall into specific categories. We have identified six types:

 

1.       Navigation applications These include full-screen (menu) applications with many buttons. The user clicks the buttons to move to different parts of the screen. Typically, the first screen that the user sees in the application allows direct navigation to the appropriate place in the application.

2.       Administration applications There are several choices for handling the administration of code description tables. The table structure for these must be decided upon first. For some developers, a clean approach works best, with a different table for each code description. However, this approach leads to a great number of tables. Other developers prefer to combine all descriptions in a single table. Choices can then be made about the look of the screen. A good strategy is to have one single administration module (or form) that supports the maintenance of all administration applications. Tables that don’t fit on one screen can be grouped on tabs within the same application.

3.        Master-detail applications A master-detail application is a standard application in which there is a parent-child relationship between two sets of records. For the current record in the master block, associated detail records are shown in the detail block.: for example, departments and their associated employees or purchase orders (POs) and their associated PO details. The master record information can be displayed in several ways: in a single-record block, multirecord block, or poplist. The detail records can be displayed in single-record or multirecord blocks. The appropriate standards for each parent of master and detail record type must be considered.

4.        Locator applications  This common type of application allows you to quickly and easily locate a specific record. For example, in a PO system, you can easily find a particular PO if you know the PO number. However, if all that you know is which department initiated the PO and that the PO was issued in the past two months, you will have problems; the Oracle Forms query facility is not sophisticated enough to support a query of this type. Therefore, to make it easy for users to locate particular records, it is customary to build a separate application that helps users locate specific records. Such an application has an area at the top of the screen to set criteria and an area at the bottom of the screen to display query results. Double-clicking a retrieved record in the locator automatically opens the primary application associated with that record and retrieves the record into the application. A locator applications can also act as a  Reports front-end passing flexible sorts, breaks and filters as lexical parameters to Oracle Reports.

5.        Complex applications These include applications with a lot of information and calculated fields. Because of the emerging Windows 95 interface standard, the best way to handle these complex forms is with tabs. According to the tab selected, the user can display different stacked canvases. In Forms 5.0, the native tab object allows editing access to all tabs, even in design mode. This feature is very useful since the developer won’t have to worry about stacked canvases. The one problem with tabs is that they take up a full line that is the height of the tab, which can be a waste of screen real estate. A big canvas that scrolls and multiple pages accessed by Next Page/Previous Page buttons are alternative ways of handling a large amount of information; however, these are now considered old-style approaches and should not be used.

6.        Assignment applications   An assignment application is one where one record is assigned to another. This is most commonly seen with many-to-many relationships. Common examples are assigning people to teams and assigning software work requests to a software version.

Each application type will use its own template. You can have a general Object Library which will be open for all applications as well as specific object libraries for each application type. It is through the combined use of specific templates and object libraries that the most dramatic improvements in the speat of forms development can be achieved.