Using Object Libraries for advanced Oracle Designer Form Generation – adding popup menus to all updateable text items

For the past four weeks, AMIS has been host to the Oracle Discovery, a training program – some might say a boot camp – for nine junior Oracle developers, just starting out their careers. The four week program included SQL, PL/SQL, Database Design & Development, Oracle Forms and Oracle Designer – the classic Oracle developer’s tools in short. We developed the program and executed the first edition of the Oracle Discovery, in association with Darwin IT

Although some may say that this is old stuff, may even wonder that AMIS is still doing ‘that old technology’- as I was in fact asked only last week – there is a lot of value in this classic Oracle technology stack. And even though AMIS is involved in several ADF (Faces) based projects along with some pure open source Java projects, we also do a lot of solid, high productive classic Oracle development. And we are far from above training young, eager developers in what we have enjoyed for so long and have become quite good at.

For myself, Form Generation has never been my daily work. While many of my colleagues were doing the hard work, actually developing applications for real customers using the Oracle development tools, I spent a lot of time creating additional development tools, doing more with the Designer API than with the Designer GUI tools. It had fallen to me to teach the last two days of the Oracle Discovery, and in order to do so, I had to revisit several topics, among which the use of Object Libraries (olb-files) in Form Generation. And once again it was evident how there is something to be learned everywhere and in everything. Especially when you think about the best ways to explain and demonstrate a concept to relative novice developers, you find things you never really realized before. And that happened to me to.

Using Object Libraries for advanced Oracle Designer Form Generation - adding popup menus to all updateable text items olb popupmenureverse 

In this article, I would like to share with you how I modified an Object Library, used when generating and compiling Forms, to add a popup menu with the options Upper, Lower, Initcap and Reverse to every updateable text field. I need to make small changes to both the Object Library and the Template Form and reference both during generation of the Form. It turns out that with a few very simple changes, I can easily add such functionality – and more like it – to all generated forms.

....
 

Steps for generating popup menus for updateable text items

1. Copy shipped Template Form ofgwebt.fmb to myofgwebt.fmb (both are in ORACLE_HOME\CGENF61\ADMIN)

The easiest way to create a Template Form is by copying one of the shipped templates and extend/embellish it. Note that ofgwebt.fmb is a very rudimentary template. Also note that with the rise of Object Libraries, we see a steep decline in relevance of the template form. The Oracle Form Generator will copy objects from the Template Form into the Generated Form. Any element in the generated form that is not generated by OFG should be in the template to be copied. Think Form Level triggers and Program Units (although these typically will be defined through Application Logic in Oracle Designer, generated into the Form or an Attached Library), Alerts, Popup Menu, Graphical Boilerplate-elements etc.

2. Copy shipped OLB Maintenance Form ofgwebol.fmb to myofgwebol.fmb (they are in the same directory)

By using a shipped Object Library (and maintenance form) I make my life easy; I do not have to create all the default CGSO$ items, I do not have to create TABs and the associated registry file. However. note that multiple Object Libraries can be attached during Generation and Compilation. So I could also (and perhaps better) create a new Object Library that is listed first during generation and complements & overrides the shipped one.

3. Modify myofgwebt.fmb (or whatever the template form is you are using)

Add program units: function get_current_value and procedure set_current_value  

FUNCTION Current_Value RETURN varchar2 IS
BEGIN
return name_in(:system.Cursor_Item);
END;

PROCEDURE set_current_value
( p_value in varchar2
) IS
BEGIN
copy( upper(p_value),:system.Cursor_Item);
END;

Create a Popup Menu, called TEXT_ITEM_MENU. Add items UPPER, LOWER, INITCAP and REVERSE, with similar labels (initcapped).

Using Object Libraries for advanced Oracle Designer Form Generation - adding popup menus to all updateable text items olb template 

Write the Menu Item Code for these items:

-- lower
begin
set_current_value( lower(current_value));
end;  

-- reverse (currently only works up to 36 characters)
begin
set_current_value( translate('abcdefghijklmnopqrstuvwxyz1234567890','0987654321zyxwvutsrqponmlkjihgfedcba',current_value));
end;

-- etc

Using Object Libraries for advanced Oracle Designer Form Generation - adding popup menus to all updateable text items olb template2 

4. Modify the Object Library Maintenance Form 

Create a dummy Popup Menu element called TEXT_ITEM_MENU. Note: alternatively, we create the TEXT_ITEM_MENU in the OLB instead of in the Template Form, then subclass it to the Template Form. It has to be in the OLB in order to create the reference from CGSO$CHAR, and it has to be in the Template Form to generate it into the generated forms.

Set the property Popup Menu for the Item CGSO$CHAR to the Popup Menu TEXT_ITEM_MENU. Make sure that this property is set to null for the CGSO$CHAR_DO (for display only) as we do not want to have this popup menu linked to display only items.

Using Object Libraries for advanced Oracle Designer Form Generation - adding popup menus to all updateable text items olb 3
 

5. Use the fm2lib61 utility to create the latest version of the Object Library

With fm2lib61.exe, we create an Object Library (olb file) from an fmb. See the file fm2lib61.txt in ORACLE_HOME\cgenf61 for more details.

First we need to create some registry settings that specify the tabs in the Object Library. Since we are using a very slightly changed version of the shipped ofgwebol.olb library, we can use the also shipped file ofgwebol.reg (also in ORACLE_HOME\cgenf61\admin) to create these registry settings.

Next, we use fm2lib61 to create an OLB from the Maintenance Form:

C:\oracle\10gDS\bin\fm2lib61.exe  -i  C:\oracle\10gDS\CGENF61\ADMIN\myofgwebol.fmb 
-o C:\oracle\10gDS\CGENF61\ADMIN\myofgwebol.olb 

6. Generate a Form from a Module with Template and Object Library referenced

From the Design Editor in Oracle Designer – where I have previously created a Module definition for a Master-Detail form on Departments and Employees – I will now generate a form with the Popup Menu attached to the Text Items. When generating, I specify the correct template form and object library:

Using Object Libraries for advanced Oracle Designer Form Generation - adding popup menus to all updateable text items olb ofg

The generated form contains the TEXT_ITEM_MENU – copied by OFG from the Template Form – and its text items subclass from CGSO$CHAR (or its more refined sub-items such as CGSO$CHAR_MD) and hence have their Popup Menu property set to TEXT_ITEM_MENU:

Using Object Libraries for advanced Oracle Designer Form Generation - adding popup menus to all updateable text items olb generatedform

 

When we run the form, we can bring up the Popup Menu using the Right Mouse Button on every (non-display only) text item:

Using Object Libraries for advanced Oracle Designer Form Generation - adding popup menus to all updateable text items olb popupmenureverse 

The contents of the item
is manipulated as instructed:

Using Object Libraries for advanced Oracle Designer Form Generation - adding popup menus to all updateable text items olb postreverse 

2 Comments

  1. site admin October 17, 2006
  2. anil madhan October 16, 2006