Gostaria de realizar o seguinte desenvolvimento:
Criar uma tabela contendo, por exemplo:
CD_MENU NUMBER(3)
NM_MENU VARCHAR2(50)
Alguém já fez algo parecido?
Muito obrigado.
[]'s
Trevisolli
CD_MENU NUMBER(3)
NM_MENU VARCHAR2(50)
Document-ID: 45638.1
Subject: "Dynamic" Menu Items
Author: DRMILLS & RPATWARI
Last Modified: 13 May 97
Simulating Dynamic Menu Items.
-------------------------------
Introduction
------------
Many applications running under MS Windows, need an useful feature to create
the menu items dynamically, which depend upon the runtime inputs from user or
from the database.
This bulletin details a way to design a menu which simulates the dynamic menu
items.
Requirement
-----------
This kind of a requerent arises in applications being deployed to the
global customers who would like to have an interface from the application
to their own forms/reports/graphics modules which are specific to them.
Assumptions
-----------
1. This bulletin assumes that you are fairly comfortable with Forms and
Menu Concepts and also assumes that you have some coding experience.
If you are uncertain how to create a menu application or how to connect
a form and a menu application, refer to the Oracle Forms User's Guide.
2. This bulletin assumes that the application being built has
an "Administration" Menu item, which contains different form modules
for administering the different database objects related to the
application.
If "Administration" menu item is not available, you need to contact your
Project Manager for placing this under appropriate menu item.
3. The approximate maximum number of Customer specific modules for
Forms/Reports is known during the design time.
Design
------
The implimentation needs :
1. A database table where the information about the Customer specific
modules will be stored. In this bulletin, it is "CUSTOMIZE_MENU".
2. A Forms interface for inputing the Customer Specific Modules
dynamically. In this bulletin, it is "APP-MENU.FMB".
3. Menu on which the changes are to be implemented.
In this bulletin, it is "MAIN.MMB".
Database Table
--------------
SQL> desc customize_menu
Name Null? Type
------------------------------- -------- ----
CM_NAME VARCHAR2(30) eg 'FRM01'
CM_TYPE VARCHAR2(30) eg 'FORMS',
'REPORTS',
'MENUITEM'
CM_MODULE VARCHAR2(30) eg 'EMPDTL.FMX'
CM_LABEL VARCHAR2(30) eg 'Employee
Details'
CM_NOTES VARCHAR2(255)
CM_DISPLAYED VARCHAR2(1) eg 'Y' or 'N'
CM_ENABLED VARCHAR2(1) eg 'Y' or 'N'
Forms Design
------------
1. Name of the Form : APP-MENU.FMB
2. The Forms interface is created with "CUSTOMIZE_MENU" as the base table,
the fields description of which is given above.
3. Unique Value for the Module name should be ensured in the form.
(Of course, at the database level also).
4. If the CM_DISPLAYED is 'Y' and CM_ENABLED' is 'N', the corresponding
menu item should be visible but greyed out.
Menu Design
-----------
1. Name of the Menu : MAIN.MMB
2. In the Menu editor, add a menu item to the Main menu with the name
"CUSTOMIZE" and without any label. The Label of this menu item will be
read from the database dynamically and replaced.
3. Create the sub menu items called 'FORMS' and 'REPORTS'.
4. In the Object Navigator, change the "Command Text" property for
"CUSTOMIZE" to "CUSTOMIZE_MENU" and the parent menu item of "FORMS" and
"REPORTS" to "CUSTOMIZE_MENU".
5. Create the sub items with names 'FRM01', 'FRM02', ..., 'FRM0n' and
'REP01', 'REP02', ..., 'REP0n' under 'FORMS' and 'REPORTS' respectively.
6. Insert a menu item called "DYNAMIC" under "Administration" Menu Item
and label it as "Customize &Menu".
7. Add or append the following PL/SQL code to the "Startup Code" property
of the Menu.
BEGIN
/* First hide all the menu items under Forms and reports and display
only the needed ones from table */
HIDE_FORMS_REPORTS_ITEM; /* Please see the code for these
procedures below. */
POPULATE_MENU_ITEMS;
END;
8. PL/SQL code for "Customize &Menu" under Administration is :
BEGIN
Call_Form('APP-MENU',NO_HIDE,DO_REPLACE);
Replace_Menu('MAIN');
/* First hide all the menu items under forms and reports and display
only */
Hide_Forms_Reports_Item;
Populate_Menu_Items;
END;
9. PL/SQL code for the MenuItems FRM01 to FRM0n is
BEGIN
Call_Module('FRM0x'); /* Where x ranges from 1 to n */
END;
10. PL/SQL code for the MenuItems REP01 to REP0n is
BEGIN
Call_Module('REP0x'); /* Where x ranges from 1 to n */
END;
Program Units
-------------
Program Unit: Hide_Forms_Reports_Item
PROCEDURE Hide_Forms_Reports_Item IS
mi_id MENUITEM;
I INTEGER;
v_forms NUMBER(2);
v_reports NUMBER(2);
BEGIN
FOR I IN 1..5 LOOP
/*
** NOTE : Assumption was that the maximum modules are known at
** design time. Change the loop counter accordingly.
*/
mi_id := Find_Menu_Item('FORMS_MENU.FRM0'||TO_CHAR(I));
Set_Menu_Item_Property( mi_id, DISPLAYED, PROPERTY_FALSE );
mi_id := Find_Menu_Item('REPORTS_MENU.REP0'||TO_CHAR(I));
Set_Menu_Item_Property( mi_id, DISPLAYED, PROPERTY_FALSE );
END LOOP;
SELECT COUNT(*)
INTO v_forms
FROM customize_menu
WHERE cm_type = 'FORMS'
AND cm_displayed = 'Y'
;
mi_id := Find_Menu_Item('CUSTOMIZE_MENU.FORMS');
IF v_forms = 0 THEN
Set_Menu_Item_Property(mi_id, DISPLAYED, PROPERTY_FALSE);
ELSE
Set_Menu_Item_Property(mi_id, DISPLAYED, PROPERTY_TRUE);
END IF;
SELECT COUNT(*)
INTO v_reports
FROM customize_menu
WHERE cm_type = 'REPORTS'
AND cm_displayed = 'Y'
;
mi_id := Find_Menu_Item('CUSTOMIZE_MENU.REPORTS');
IF v_reports = 0 THEN
Set_Menu_Item_Property(mi_id, DISPLAYED, PROPERTY_FALSE);
ELSE
Set_Menu_Item_Property(mi_id, DISPLAYED, PROPERTY_TRUE);
END IF;
mi_id := Find_Menu_Item('MAIN_MENU.CUSTOMIZE');
Set_Menu_Item_Property(mi_id, DISPLAYED, PROPERTY_TRUE);
IF v_forms = 0 and v_reports = 0 THEN
Set_Menu_Item_Property(mi_id, DISPLAYED, PROPERTY_FALSE);
ELSE
Set_Menu_Item_Property(mi_id, DISPLAYED, PROPERTY_TRUE);
END IF;
END; /* End of Procedure Hide_Forms_Reports_Item */
Program Unit: Populate_Menu_Items
PROCEDURE Populate_Menu_Items IS
mi_id MenuItem;
menufound BOOLEAN := FALSE;
Cursor C1 is
Select * from customize_menu;
BEGIN
FOR C IN C1 LOOP
IF c.cm_type = 'MENUITEM' THEN
menufound := TRUE;
mi_id := Find_Menu_Item('MAIN_MENU.CUSTOMIZE');
Set_Menu_Item_Property(mi_id, LABEL, c.cm_label);
ELSE
mi_id := Find_Menu_Item(c.cm_type || '_MENU.' || c.cm_name);
Set_Menu_Item_Property(mi_id, LABEL, c.cm_label);
mi_id := Find_Menu_Item(c.cm_type || '_MENU.' || c.cm_name);
Set_Menu_Item_Property(mi_id, LABEL, c.cm_label);
IF c.cm_module IS NULL THEN
Set_Menu_Item_Property(mi_id, DISPLAYED, PROPERTY_FALSE);
ELSE
Set_Menu_Item_Property(mi_id, DISPLAYED, PROPERTY_TRUE);
IF UPPER(c.cm_displayed) = 'N' THEN
Set_Menu_Item_Property(mi_id, DISPLAYED, PROPERTY_FALSE);
ELSIF UPPER(c.cm_displayed) = 'Y' and UPPER(c.cm_enabled) = 'N'
THEN
Set_Menu_Item_Property(mi_id, ENABLED, PROPERTY_FALSE);
ELSE
Set_Menu_Item_Property(mi_id, ENABLED, PROPERTY_TRUE);
END IF;
END IF;
END IF;
END LOOP;
/* If Modulename is not entered for the Menu item, defaults to Customize. */
IF NOT menufound THEN
Set_Menu_Item_Property('MAIN_MENU.CUSTOMIZE', LABEL, 'C&ustomize');
END IF;
END; /* End of Procedure Populate_Menu_Items */
Program Unit: Call_Module
PROCEDURE Call_module ( p_cm_name Varchar2) IS
v_cm_type varchar2(30);
v_cm_module varchar2(30);
BEGIN
SELECT cm_type, cm_module
INTO v_cm_type, v_cm_module
FROM customize_menu
WHERE cm_name = p_cm_name;
IF v_cm_type = 'FORMS' THEN
Call_Form( v_cm_module, HIDE, NO_REPLACE );
ELSE
Run_Product( REPORTS, v_cm_module, SYNCHRONOUS, RUNTIME,
FILESYSTEM, NULL, NULL );
END IF;
EXCEPTION
WHEN OTHERS THEN
MESSAGE('When Others error...'||sqlerrm);
END;
Other Considerations
--------------------
1. You can assign menu roles for the above menu items to restrict the group
of users from accessing these menu items.
Benefits of this approach
-------------------------
1. Since this method depends upon the database as the storage and retrieval
for the Dynamic forms and reports, all the multiuser locking issues,
security etc. are taken care automatically.
2. Once the user enters the Modulename etc., the changes are effected
immediately after exiting the Form. There is no need to logout/login
again.
3. The sub menu items like 'FORMS' and 'REPORTS' will be displayed, if and
only if there are any modules named under their category.
Limitations of this approach
----------------------------
1. The maximum number of modules should be known during the design time.
Usuários navegando neste fórum: Nenhum usuário registrado e 10 visitantes