Beruflich Dokumente
Kultur Dokumente
Author
Ian Purvis
Copyright Oracle Corporation, 2000. All rights reserved. This documentation contains proprietary information of Oracle Corporation. It is provided under a license agreement containing restrictions on use and disclosure and is also protected by copyright law. Reverse engineering of the software is prohibited. If this documentation is delivered to a U.S. Government Agency of the Department of Defense, then it is delivered with Restricted Rights and the following legend is applicable:
Publisher
Nita Brozowski
Contents .....................................................................................................................................................
Contents
Preface Profile xv Related Publications xvi Typographic Conventions xvii Introduction Introduction I-2 Course Content I-3 Lesson 1: Creating a Menu Module Introduction 1-3 Components of the Menu Module 1-5 The Default Menu 1-7 The Menu Editor 1-9 Creating a Menu Module 1-11 Module Properties 1-13 Menu Properties 1-15 Menu Item Properties 1-17 Menu Item Types 1-19 Menu Item Command Types 1-21 Implementing Menu Toolbars 1-23 Storing the Menu Module 1-25 Attaching the Menu Module 1-27 Pop-up Menus 1-29 Summary 1-31 Practice Overview: Lesson 1 1-33 Practice 1 1-34 Lesson 2: Managing Menu Modules Introduction 2-3 Using PL/SQL in Menu Item Code 2-5 Useful Built-in Menu Subprograms 2-7
Contents .....................................................................................................................................................
Showing and Hiding the Current Menu 2-9 Managing Menu Security 2-11 Defining Security Roles 2-13 Assigning Access to Menu Items 2-15 Summary 2-17 Practice Overview: Lesson 2 2-19 Practice 2 2-20 Lesson 3: Programming Function Keys Introduction 3-3 Key Triggers 3-5 Defining Key Triggers 3-7 Characteristics of Key Triggers 3-9 Classification of Key Triggers 3-11 Using Key Triggers 3-15 Association with Other Interface Controls 3-17 Summary 3-19 Practice Overview: Lesson 3 3-21 Practice 3 3-22 Lesson 4: Responding to Mouse Events Introduction 4-3 What Are Mouse Events? 4-5 Responding to Mouse Movement 4-7 Responding to Mouse Button Actions 4-11 Summary 4-15 Practice Overview: Lesson 4 4-17 Practice 4 4-18 Lesson 5: Controlling Windows and Canvases Programmatically Introduction 5-3 Using Window-Interaction Triggers 5-5 Built-ins for Manipulating Windows 5-7 Built-ins for Manipulating Canvases 5-9
Contents .....................................................................................................................................................
Working with Tab-Style Canvases 5-11 Windows and Blocks 5-15 Manipulating Window Properties Programmatically 5-17 Closing Windows 5-19 Manipulating Windows in Web-Deployed Forms 5-21 Sizing Windows for Web-Deployed Forms 5-23 Display Large Data Blocks in a Window 5-25 Managing Images for Web-Deployed Forms 5-27 Summary 5-29 Practice Overview: Lesson 5 5-31 Practice 5 5-32 Lesson 6: Defining Data Sources Introduction 6-3 Data Source Types 6-5 Basing a Data Block on a FROM Clause Query 6-7 Basing a Data Block on a Stored Procedure 6-9 Example of a Query Using a REF Cursor Procedure 6-11 Example of Query Using a Table of Records Procedure 6-13 Example of DML Using a Stored Procedure 6-15 Deciding Whether to Use a REF Cursor or a Table of Records 6-17 Data Block Wizard 6-19 Data Block Properties 6-21 Data Source Guidelines 6-23 Summary 6-27 Practice Overview: Lesson 6 6-29 Practice 6 6-30 Lesson 7: Working with Oracle8i Objects in Form Builder Introduction 7-3 What Are Object Types? 7-5 Review of Objects 7-7 Object REFs 7-9 Supported Oracle8i Features 7-11
Contents .....................................................................................................................................................
How Oracle Forms Developer Treats Objects 7-13 Object Type Displays 7-15 Creating Data Blocks Based on Oracle8i Objects 7-17 Selecting Object Table Columns 7-19 Selecting Object Column Attributes 7-21 Blocks with REF Lookups 7-23 The REF Column Value 7-25 LOVs for REFs 7-27 Summary 7-29 Practice Overview: Lesson 7 7-31 Practice 7 7-32 Lesson 8: Controlling Data Block Relationships Introduction 8-3 Creating a Relation 8-5 Block Coordination 8-7 Coordinate Blocks Using REFs 8-9 Characteristics of Relation-Handling Triggers 8-11 Principles of Relation-Handling Code 8-13 Obtaining Relation-Handling Information 8-15 Implementing a Coordination-Type Toggle 8-17 Forcing a Commit Per Master 8-19 Summary 8-21 Practice Overview: Lesson 8 8-23 Practice 8 8-24 Lesson 9: Building Multiple Form Applications Introduction 9-3 OPEN_FORM to Invoke Additional Forms 9-5 Closing Forms 9-7 Navigating Between Forms 9-9 Transaction Processing for Opened Forms 9-11 CALL_FORM to Invoke Additional Forms 9-13 Transaction Processing for Called Forms 9-15
Contents .....................................................................................................................................................
NEW_FORM to Invoke Additional Forms 9-19 Controlling Open Forms and Called Forms Together 9-21 Different Ways of Invoking Forms 9-23 Using Form Parameters 9-25 Parameter Lists 9-29 Creating and Manipulating Parameter Lists 9-31 Passing Data Between Forms 9-33 Summary 9-35 Practice Overview: Lesson 9 9-37 Practice 9 9-38 Lesson 10: Working with Record Groups Introduction 10-3 Record Groups 10-5 Using Record Groups 10-7 Defining Record Groups at Design Time 10-9 Built-in Functions for Controlling Record Groups 10-11 Defining Query Record Groups Programmatically 10-17 Defining Nonquery Record Groups Programmatically 10-19 Manipulating Record Group Rows 10-21 Manipulating Selected Record Group Rows 10-23 Defining Global Record Groups 10-25 Manipulating List Items Programmatically 10-27 Implementing Dynamic List Items 10-29 Adding Values to Combo Boxes 10-31 Summary 10-33 Practice Overview: Lesson 10 10-35 Practice 10 10-36 Lesson 11: Using Reusable Components Introduction 11-3 Reusable Components 11-5 Reusable Components List 11-7 The Calendar Class 11-11
Contents .....................................................................................................................................................
Calendar Object Group Content 11-13 Built-in for Manipulating the Calendar 11-15 Summary 11-17 Practice Overview: Lesson 11 11-19 Practice 11 11-20 Lesson 12: Using Java with Web-Deployed Forms Introduction 12-3 Java and Oracle Forms Developer 12-5 Java in Web-Deployed Forms 12-7 The Forms Applet 12-9 Defining Fonts for Web-Deployed Forms 12-11 Pluggable Java Components 12-13 What Is a Bean Area? 12-17 Hosting a JavaBean 12-19 How a JavaBean Communicates 12-21 Communicating with the JavaBean 12-23 Exploiting Oracle8i Features 12-25 How to Create JavaBeans 12-27 Summary 12-29 Practice Overview: Lesson 12 12-31 Practice 12 12-32 Lesson 13: Using Server Features in Form Builder Introduction 13-3 Using Oracle Database Server Functionality in Forms 13-5 Dealing with PL/SQL Code 13-7 PL/SQL8 Support 13-9 PL/SQL8 Scalar Data Types 13-11 Unsupported Oracle Forms Developer PL/SQL8 Features 13-13 Handling Errors Raised by the Oracle Database Server 13-15 Performing DDL with FORMS_DDL 13-19 Using FORMS_DDL 13-21 Summary 13-23
Contents .....................................................................................................................................................
Practice Overview: Lesson 13 13-25 Practice 13 13-26 Lesson 14: Applying Timers Introduction 14-3 Timers 14-5 Handling Timer Expiration 14-7 Creating a Timer 14-9 Modifying a Timer 14-11 Deleting a Timer 14-13 Summary 14-15 Practice Overview: Lesson 14 14-17 Practice 14 14-18 Lesson 15: Including Charts and Reports Introduction 15-3 Including Charts by Using the Chart Wizard 15-5 Chart Item Properties 15-11 Reporting Within Form Builder 15-13 Report Object Properties 15-15 Working with Reports 15-17 Summary 15-23 Practice Overview: Lesson 15 15-25 Practice 15 15-26 Appendix A: Practice Solutions Practice 1 Solutions A-2 Practice 2 Solutions A-6 Practice 3 Solutions A-8 Practice 4 Solutions A-10 Practice 5 Solutions A-11 Practice 6 Solutions A-13 Practice 7 Solutions A-14 Practice 8 Solutions A-15
Contents .....................................................................................................................................................
Practice 9 Solutions A-18 Practice 10 Solutions A-21 Practice 11 Solutions A-24 Practice 12 Solutions A-27 Practice 13 Solutions A-30 Practice 14 Solutions A-32 Practice 15 Solutions A-34 Appendix B: Table Descriptions and Data Summit Sporting Goods Database Diagram B-2 S_CUSTOMER Description B-3 S_CUSTOMER Data B-4 S_DEPT Description and Data B-8 S_EMP Description B-9 S_EMP Data B-10 S_ITEM Description B-13 S_ITEM Data B-14 S_ORD Description and Data B-16 S_PRODUCT Description B-17 S_PRODUCT Data B-18 S_REGION Description and Data B-22 S_TITLE Description and Data B-23 Oracle8i Objects: Types, Tables B-24 Appendix C: Mouse Movement Events Introduction C-2 Drag and Drop C-4 Summary C-6 Appendix D: Introduction to Oracle8i Object Features Introduction D-3 New Oracle8i Data Types D-5 Object Types D-7 Creating Oracle8i Objects D-11
Contents .....................................................................................................................................................
Object Columns D-13 Object Views D-15 INSTEAD-OF Triggers D-17 Referencing Objects D-19 Displaying Oracle8i Objects in the Object Navigator D-21 Summary D-29 Appendix E: Menu Run-Time Parameters Introduction E-3 Substitution Parameters E-5 Defining a User-Named Substitution Parameter E-7 Substitution Parameter Built-ins E-9 Validating a Substitution Parameter Value E-11 Summary E-13 Appendix F: Handling Server-Side Errors Introduction F-3 Obtaining the Cause of Declarative-Constraint Violations F-5 Customizing Oracle Server Error Messages F-7 Example Procedure for Handling Oracle Server Errors F-9 Summary F-13 Appendix G: EMP_PKG Package Package Specification G-2 Package Body G-4 Appendix H: Working with ActiveX Controls Introduction H-3 What Are VBX, OCX, and ActiveX Controls? H-5 Comparison of VBX, OCX, and ActiveX Controls H-7 ActiveX in Form Builder H-9 Implementing an ActiveX Control H-11 Inserting an ActiveX Control in an ActiveX Control Item H-13 Importing ActiveX Control Methods and Events Packages H-15 Setting and Getting ActiveX Control Properties H-17
Contents .....................................................................................................................................................
Invoking ActiveX Control Methods H-21 Responding to ActiveX Control Events H-23 Handling Exceptions H-25 Registering an ActiveX Control H-27 Summary H-29 Appendix I: Using Oracle Server Roles at Run Time Using Oracle Server Roles at Run Time I-3 Procedures for Managing Roles I-7
Preface
.................................
Preface .....................................................................................................................................................
Instructor Note General course information for instructors: PowerPoint Slides The slide show provides many builds to facilitate your explanation. Of course, you can modify these builds if you prefer, depending upon your familiarity with PowerPoint. All slides include a small arrow at the bottom of the screen that is displayed on the final build, so that you know when one slide finishes and the next slide begins. On the last slide of a lesson the arrow points to the left instead of the right. If you modify a build, make sure that this arrow is the last object in the build order. Demonstrations A set of demonstrations is provided to help you with your explanations. If there is more than one Web deployed demo form module within a lesson, you can use the appropriate lesson Webmenu form module to launch your demos. Practice Sessions Students might want to view the form that they are asked to produce in each question. Solution files of all forms are available in the SOLNS directory.
Profile .....................................................................................................................................................
Profile
Before You Begin This Course Before you begin this course, you should have the following qualifications: Thorough knowledge of: - Creating simple applications with Oracle Forms Developer Form Builder - Creating SQL query statements Working experience of: - Creating PL/SQL constructs, including conditional statements, procedures, and functions - Creating PL/SQL stored (server) procedures and functions Knowledge of using a graphical user interface (GUI) Knowledge of using a Web browser, and downloading HTML pages with a Uniform Resource Locator (URL) Prerequisites The following instructor-led training (ILT) course: Oracle Forms Developer: Build Internet Applications I Suggested Follow-up Courses Oracle Reports Developer: Build Internet Reports Oracle Forms Server: Deploy Internet Applications How This Course Is Organized Oracle Forms Developer: Build Internet Applications II is an instructor-led course featuring lectures and hands-on exercises. Online demonstrations and written practices reinforce the concepts and skills introduced.
Preface .....................................................................................................................................................
Related Publications
Oracle Publications
Title Oracle Forms Developer and Oracle Reports Developer Guidelines for Building Applications, Release 6i Oracle Forms Developer Getting Started, Release 6i A73154-01 Part Number A73073-02
Typographic Conventions
Typographic Conventions in Text
Convention Bold italic Caps and lowercase Element Glossary term (if there is a glossary) Buttons, check boxes, triggers, windows Code output, directory names, filenames, passwords, pathnames, URLs, user input, usernames Graphics labels (unless the term is a proper noun) Emphasized words and phrases, titles of books and courses, variables Interface elements with long names that have only initial caps; lesson and chapter titles in cross-references SQL column names, commands, functions, schemas, table names Example The algorithm inserts the new key. Click the Executable button. Select the Cant Delete Card check box. Assign a When-Validate-Item trigger . . . Open the Master Schedule window. Code output: debug.seti('I',300); Directory: bin (DOS), $FMHOME (UNIX) Filename: Locate the init.ora file. Password: Use tiger as your password. Pathname: Open c:\my_docs\projects URL: Go to http://www.oracle.com User input: Enter 300 Username: Log on as scott Customer address (but Oracle Payables)
Initial cap
Italic
Quotation marks
Do not save changes to the database. For further information, see Oracle7 Server SQL Language Reference Manual. Enter user_id@us.oracle.com, where user_id is the name of the user. Select Include a reusable module component and click Finish. This subject is covered in Unit II, Lesson 3, Working with Objects.
Uppercase
Use the SELECT command to view information stored in the LAST_NAME column of the EMP table.
Preface .....................................................................................................................................................
Example Select File>Save. Press [Enter]. Press and release these keys one at a time: [Alt], [F], [D] Press and hold these keys simultaneously: [Ctrl]+[Alt]+[Del]
Typographic Conventions in Navigation Paths This course uses simplified navigation paths, such as the following example, to direct you through Oracle Applications. (N) Invoice>Entry>Invoice Batches Summary (M) Query>Find (B) Approve This simplified path translates to the following: 1 (N) From the Navigator window, select Invoice>Entry>Invoice Batches Summary. 2 (M) From the menu bar, select Query>Find. 3 (B) Click the Approve button. N = Navigator, M = Menu, B = Button
I
................................
Introduction
Introduction
Aim of the Course After completing this course, you should be able to do the following: Create, modify and attach menu documents to Oracle Forms Developer Internet applications Ensure application security with Oracle8i database roles Code triggers that respond to function keys Mouse movement and mouse button actions Window and Canvas manipulation Choose appropriate data sources for data blocks Work with Oracle8i objects in Form Builder Create and manage multiple Internet form applications Manage transaction processing in multiple Oracle Forms Developer Internet applications Create and modify Record Groups programmatically Build forms with Reusable Components Enhance the User Interface with JavaBeans Manage Server side features Create Timers Include charts and reports in Oracle Forms Developer Internet applications
Course Content
The lesson titles show the topics we cover in this course, and the usual sequence of lessons. However, the daily schedule is an estimate, and may vary for each class. Day 1
Lesson Number 1 2 3 4 Lesson Name
Creating a Menu Module Managing Menu Modules Programming Function Keys Responding to Mouse Events
Day 2
Lesson Number 5 6 7 8 9 Lesson Name
Controlling Windows and Canvases Programmatically Defining Data Sources Working with Oracle8i Objects in Form Builder Controlling Data Block Relationships Building Multiple Form Applications
Day 3
Lesson Number 10 11 12 13 14 15 Lesson Name
Working with Record Groups Using Reusable Components Using Java with Web-Deployed Forms Using Server Features in Form Builder Applying Timers Including Charts and Reports
1
................................
Objectives
Identify the components of a menu Create, save, and attach menu modules Set menu properties by using the Property Palette Create menu toolbars Create pop-up menus
Instructor Note
Topic Lecture Practice Total Timing 50 minutes 40 minutes 90 minutes
Introduction ......................................................................................................................................................
Introduction
Overview By default, each form module uses the same menu structure, called the Default menu. This lesson teaches you how to customize this menu and how to create your own menu modules. You will also learn how to enhance your application by including menu toolbars and pop-up menus. Objectives After completing this lesson, you should be able to do the following: Identify the different components of a menu module Create, save, and attach menu modules Set menu properties by using the Property Palette Create menu toolbars Create pop-up menus
Main menu
Menu module
Individual menu
Menu item
Menu item
Individual menu
Menu items
Submenu
Menu items
Instructor Note Demonstration: Use orders.fmb to explain the components. Open the Default menu, menudef.mmb, to illustrate the hierarchical structure of a menu.
Default Menu
Query Enter Execute Cancel Last Criteria Count Hits Fetch Next Set
Block
Record
Previous Previous Next Next Clear Scroll Up Scroll Down Insert Remove Lock Duplicate Clear
Instructor Note Open the Default menu (menudef.mmb), and show the menu items in the menu editor.
Menu tab
Expanded menu
Collapsed menu
Technical Note By default, the Menu Editor displays a pull-down menu, with the top-level menu displayed horizontally. If you are developing a full-screen menu, you may want to display the top-level menu vertically, so that the display matches the way your menu will appear at run time. To change the orientation, click the Switch Orientation button. Instructor Note In the Menu Editor, the key sequences [Ctrl] + the down arrow and [Ctrl] + the right arrow create, respectively, a menu item below and to the right of an existing object. Use the Default menu (menudef.mmb) to show the Menu Editor functionalities. Show the steps to move a menu or a menu item. Show the steps to copy a menu to another level. Demonstrate that if you move a submenu to a parent item with the Command Type property set to PL/SQL or Null, Form Builder displays an alert.
Main Menu Menu Directory Menu Filename Startup Code Share Library with Form
Instructor Note Do not spend a long time going through all the menu module properties; instead point out that they are here for convenience. Also, context-sensitive help is available.
Module Properties
Property Main Menu Description Property that specifies the name of the individual menu in the module that is the main or starting menu at run time For a pull-down menu, the main menu is automatically set to the name of the first menu that you create. Users cannot navigate above this menu in the menu hierarchy. Menu Directory Menu Filename Startup Code Share Library with Form Use Security Path used by Forms as a pointer to the directory for the run-time .mmx file; only used by menu modules that are saved to the database Filename used by Forms as a pointer to the run-time .mmx file; only used by menu modules that are saved to the database PL/SQL code executed when a menu module is loaded in memory Property that enables to be loaded in memory a single copy of a PL/ SQL library, if this library is used by the form module and the menu module Property that when set to Yes enforces security at run time (Set this property to No to test the menu module without having to be a member of any database role.) Property that displays the Menu Module Roles dialog box, where you can list the roles assigned to the menu module (Roles defined must be assigned to individual menu items in the Menu Editor.)
Module Roles
Menu Properties
Instructor Note The Tear-Off property is available for the Motif window manager.
Menu Properties
Property Tear-Off Menu Description Enables the menu to be dragged from the menu bar and repositioned elsewhere on the screen (available only if your window manager supports this feature)
Enabled Label Menu Item Type Magic Item Menu Item Radio Group
Command Type
Technical Note Radio menu items must belong to a radio group. All of the radio items for a radio group must be contiguous on the same menu. Radio group names are internal names that are not displayed at run time. Instructor Note The mappings of logical accelerator keys to physical device keys are defined in the run-time resource file. You must edit the resource file in Oracle Terminal to change the key mappings. You can also create additional accelerator keys in Oracle Terminal (ACCELERATOR6, ACCELERATOR7, and so on), which you can then associate with menu items in a menu module. If you wish to maintain key mapping for Web-deployed forms, you will need to edit the FMRWEB.res file; this does not require Oracle Terminal. .
Defining Menu Access Keys Forms indicates an access key by underlining one special character in the menu item. Users can then issue the menu item command by pressing a key combination such as [Alt] + [character]. Specifying the Underline Character
Development execute query eXecute query Exe&cute Query Execute &Query Run Time execute query eXecute query Execute Query Execute Query
Plain Check
Radio
Magic
Separator
Magic Items
Separator Magic
Magic Items Some Magic menu items include default functionality. Because a Magic item provides the standard actions of a graphical user interface (GUI), a copy or paste action is already defined at the menu level. All you need to do is set the item to the Magic type and define the desired action (standard or specific).
Magic Item About Undo Clear Copy Paste Cut Help Command Type Any except Menu Null Default Functionality? No. You must assign a command to these items to perform the desired function. Yes. These items perform the default operations indicated by their names.
Menu
Quit
Null
Window
Null or Menu
No. You must define a submenu to be called by the Magic Help item, and you must assign commands to the items on that submenu. Yes. The Quit command, by default, exits from the form after asking the user to save any changes. Yes. The window item invokes a default submenu that lists all open windows. Users can activate a window by selecting it from the submenu.
Does not issue a command Invokes a submenu Executes a PL/SQL command Spawns a process to SQL*Plus Backward compatibility Backward compatibility
Plus
Note: The command types of Form, Plus and Macro are available for backward compatibility only. Web Design Tip If you invoke the HOST command with Web-deployed forms, the required process will run on the Web Server, not on the client. The client will not be able to view nor participate in that process. Viewing Menu Item Commands To view the menu item command associated with a menu item, you must take one of the following actions: Double-click the icon to the left of the menu item entry in the Object Navigator Use the Menu Item Code or Submenu Name property in the Property Palette Right-click on the menu item in the Object Navigator or Menu Editor and select PL/SQL Editor from the pop-up menu
Contains only buttons corresponding to menu items Is displayed above normal toolbars Executes the same code as menu items Is enabled and disabled, visible and hidden, in synchronization with corresponding menu item
Technical Note For more flexible or complex requirements, use the existing Toolbar canvas in form modules. Instructor Note The Default menu toolbar works very well; however, building your own menu and menu toolbar is not so easy. For example, you have to create separator items for every space that you require to group the items. Also, the menu toolbar icons appear in exactly the same order as the menu options, which might not be what you want. Demonstration: Use the menu that you created earlier, and set the properties to display the Save option in a menu toolbar. Use the save.ico file.
Stored in files
Stored in files
You can save your menu module definition by either of the following actions: Clicking the Save icon in the Object Navigator Selecting File>Save Creating an Executable Version Before you can use your customized menu module, you must create an executable version. To do so, select File>Administration>Compile File. The resulting file that you create has the .mmx extension. A menu module executable file containing binary code is not portable between operating systems.
Technical Note If you want to use the Default menu without the associated menu toolbar, replace the value DEFAULT&SMARTBAR in the Menu Module property with DEFAULT only.
Enables users to access commonly used functions easily Is accessed by pressing the right mouse button (Microsoft Windows and Motif)
Pop-up menus are: Top-level objects in the object navigator, such as alerts or Data Blocks Built through the Property Palette or Menu Editor Defined in a form module Associated with items and canvases with a pop-up menu property
Instructor Note Demonstration: Use customers.fmb to demonstrate the pop-up menu. Navigate to the Comments item, and click the right mouse button.
Pop-up Menus
Pop-up menus are context-sensitive menus. You attach pop-up menus to an item or canvas, and display them by right click on that item or canvas. Pop-up menus enable end users to quickly access common functions and commands. Pop-up menus are top-level objects in the Object Navigator (similar to alerts, blocks, canvases, and so on) and belong to a form module (as opposed to form menus, which belong to a separate menu module). Items on a pop-up menu should be contextual to the menu's associated objects. For example, you would not include text-editing items on the pop-up menu for a two-digit numeric item. However, you might include such items on the pop-up menu for a multiline text item. Incorporating Pop-up Menus 1 In the Object Navigator of a form, click the Pop-up Menus node, and click the Create button on the toolbar. Form Builder creates a pop-up menu and gives it a default name, such as MENU1. 2 In the Object Navigator or Menu Editor, create a main pop-up menu, submenus (if any), and menu items. 3 Assign commands to the menu items. You can select plain text, separators, check boxes, and option boxes for Menu items. 4 Attach the menu to items and canvases with a new Pop-up Menu property. Rules for Incorporating Pop-up Menus To show pop-up menus for a canvas, the mouse must be on the canvas only. Pop-up menu items can be parents of submenus (if the platform allows it), magic menu items, or separators. Pre-Popup-Menu Trigger You can use this trigger to add dynamic control at run time, prior to displaying the menu. For example, you can use the trigger to identify the cursor context and navigate to a different item if necessary.
Summary
Create a Menu module Associate Menu and form modules Create a Pop-up menu
Summary ......................................................................................................................................................
Summary
In this lesson, you learned how to add, create, and customize menu modules. The Menu Module Components Main menu Menu Menu item Menu toolbar The Default Menu Automatically used with every form module Can be customized Creating a Menu Module Properties Menu module properties Menu properties Menu item properties Implementing a Menu Toolbar Menu Module Storage Database tables .mmb file extension .mmx file extension .mmt file extension Menu Module and Form Module Association Using the form module properties of Menu Module and Menu Source Creating a Pop-up Menu Incorporate pop-up menus Rules to incorporate pop-up menus Pre-Popup-Menu trigger
Practice 1 Overview
Creating a simple menu module Incorporating some of the menu items in the menu toolbar Compiling and attaching the menu to the ORDERS form Creating a pop-up menu
Instructor Note The practice overview in this lesson and the ones that follow are provided only as guides. Outline the practice in the level of detail appropriate for the course participants. For this lab, use the DO_KEY built-in. At this stage of the course, students do not yet know this built-in. Explain it briefly and tell them that it is covered in detail in Lesson 3.
Practice 1
1 Create a new menu module. a
Using the following screenshot as a guideline, create a new menu module called M_SUMMITXX where XX is your student course number.
File Menu
Menu Item Type Plain Visible in Menu Yes Visible in Horiz. Menu Toolbar Yes
Label Save
Clear
Plain
PL/SQL
Yes
Yes
Abort
Null1 Exit
Separator Plain
Yes Yes
Null2
Separator
Null
No
Yes
Practice 1 ......................................................................................................................................................
Edit Menu
Menu Item Type Magic Magic Magic Separator Magic Item Cut Copy Paste Command Type Null Null Null Null Visible in Menu Yes Yes Yes No Visible in Horiz. Menu Toolbar Yes Yes Yes Yes Icon Filename Cut Copy Paste
Sort By Menu
Menu Item Type Menu Item Radio Group Order_By Command Type
Menu Label
Order Id
Radio
PL/SQL
SET_BLOCK_PROPERTY( s_ord, order_by, id ) ; SET_BLOCK_PROPERTY( s_ord, order_by, customer_id ) ; SET_BLOCK_PROPERTY( s_ord, order_by, sales_rep_id ) ;
Customer Id
Radio
Order_By
PL/SQL
Sales Rep Id
Radio
Order_By
PL/SQL
Query Menu
Menu Item Type Plain Plain Command Type PL/SQL PL/SQL Visible in Horiz. Menu Toolbar Yes Yes Icon Filename query execute
Save as M_SUMMIT and compile the menu module. c Attach the menu module to the ORDERS form. d Save and compile the form module as ORDGXX where XX is your student course number. e Run and test your ORDERS form. 2 Add pop-up menus to the CUSTOMERS form. a Open the CUSTOMERS form module. Save as CUSTGXX where XX is your student course number. b Copy the EDIT_MENU menu from your M_SUMMIT menu module to your CUSTOMERS form. Attach this pop-up menu to the Comments item. c Save and compile the form module. Deploy your form to the Web to test.
b
2
................................
Objectives
Control the menu programmatically Manage the interaction between the menu and form documents Implement application security through the menu
Instructor Note
Topic Lecture Practice Total Timing 40 minutes 30 minutes 70 minutes
Introduction ......................................................................................................................................................
Introduction
Overview In this lesson, you will learn how to modify menus dynamically, as well as how to control application security through menu access. Objectives After completing this lesson, you should be able to do the following: Control the menu programmatically by using menu built-ins Implement menu security by using both database roles and the appropriate built-ins
Instructor Note The DO_KEY built-in is explained in the next lesson. Stress that it is very important to use this built-in for generic coding.
Instructor Note Demonstration: Use m_summit.mmb file to show examples of these built-ins.
Example This procedure finds the ID of a menu item before setting multiple properties.
DECLARE mi_id MenuItem; BEGIN mi_id := Find_Menu_Item(Preferences.AutoCommit); /* Determine the current checked state of the AutoCommit menu checkbox item and toggle the checked state */ IF Get_Menu_Item_Property(mi_id,CHECKED) = TRUE THEN Set_Menu_Item_Property(mi_id,CHECKED,PROPERTY_FALSE); ELSE Set_Menu_Item_Property(mi_id,CHECKED,PROPERTY_TRUE); END IF; END;
Technical Note REPLACE_MENU replaces the menu for all windows in the application. If you are using CALL_FORM, REPLACE_MENU replaces the menu for both the calling form and the called form with the specified menu.
Example Use a standard procedure to change which root menu in the current menu application appears in the menu bar. A single menu application may have multiple root menus, which an application can set dynamically at run time.
PROCEDURE Change_Root_To(root_menu_name VARCHAR2) IS BEGIN Replace_Menu(MYAPPLSTD, PULL_DOWN, root_menu_name); END;
Defining security roles Choosing roles for the menu module Assigning access to menu items Setting the Use Security property
What Is a Role?
Users
Role
Privileges
Set to Yes to enforce security Set to No to ignore security: Enables the developer to test the application
Technical Note If Use Security is modified, you must recompile the menu module.
Assigning Roles to the Menu Module To associate a particular role with a menu item, you must define all the roles used in that menu module: 1 In the Object Navigator, select the menu module. 2 In the Properties window, select the Menu Module Roles property. 3 Click More... to open the Menu Module Roles dialog box. 4 Enter the names of the roles that you want to choose for this menu module. 5 Click OK to accept the roles list. Note: The role must exist in the database. Setting the Use Security Property The Use Security property determines whether Form Builder should take account of the specified roles at run time. When Use Security is set to Yes, Forms enforces security. When Use Security is set to No: Forms ignores security. Your users can access all menu items. You can test your application without being a member of all roles.
Instructor Note You can manipulate roles dynamically at run time by using Form Builder. For example, you can select views from the data dictionary to get information about existing roles. Subprograms belonging to the DBMS_SESSION package enable you to modify the roles that are used by the menu module to enforce security. Tell students that if they want more details about DBMS_SESSION, they can read Appendix I, Using Oracle Server Roles at Run Time.
Summary
Exploit Menu Built-ins Include PL/SQL in menu items Implement menu security
Summary ......................................................................................................................................................
Summary
PL/SQL in Menu Item Commands Typical PL/SQL uses Restrictions for PL/SQL in menu item commands Built-ins for Use with Menu Modules Showing and hiding the current menu: - HIDE_MENU - REPLACE_MENU - SHOW_MENU - MENU_REDISPLAY Getting and setting menu properties: - FIND_MENU_ITEM - GET_MENU_ITEM_PROPERTY - SET_MENU_ITEM_PROPERTY
Practice 2 Overview
Enhancing the menu with a check menu item Synchronizing the menu Display_Help item with the form Help button Hiding irrelevant menu items according to form context
Instructor Note The practice overview in this lesson and the ones that follow are provided only as guides. Develop the practice with the level of detail appropriate for the students. This lab uses a lot of PL/SQL code. Because this is not a coding course, we provide the code. Take time to explain this practice so that students understand the code that they will import.
Practice 2
1 Define a check menu item. a
Open your M_SUMMIT menu module and add a new menu item to the Sort By menu; name it Display_Help.
Menu Label Menu Item Type Command Type
Display Help
b
Check
PL/SQL
If Display_Help is selected, enable the ORDERS form toolbar HELP button and set the toolbar canvas background color to grey. If Display_Help is not selected, disable the ORDERS form toolbar HELP button and set the toolbar canvas background color to red. You can import the code from the pr2_1.txt file. c Save and compile the menu module. Deploy your menu on the Web. d Deploy your ORDERS form on the Web to test your menu.
2 Synchronize the menu module with the form.
Write startup code for your M_SUMMIT menu module that synchronizes the Display_Help menu item with the toolbar HELP button. You can import the code from the pr2_2.txt file. b Save and compile your menu module. Deploy to the Web. c Deploy your ORDERS form on the Web to test your menu.
a 3 Attach your M_SUMMIT menu to your CUSTOMERS form. The menu
item Sort_By is not relevant, and should not be visible to the user. a Attach the menu module to your CUSTOMERS form. b Modify the startup code of the M_SUMMIT menu module to hide the SORT_BY menu when the CUSTOMERS form is opened. You can import the code from the pr2_3.txt file to replace the existing code. You may need to change the code to conform to the exact names you gave to the Main Menu and its menu items. c Save and compile the menu module; deploy your menu to the Web. d Deploy your CUSTOMERS form to the Web and test your application. Execute a Query and click the Orders button to move to the ORDERS form. Note that the Sort_By menu item is hidden when the CUSTOMERS form is current, and is visible when the ORDERS form is current. 4 With both the ORDERS and CUSTOMERS form modules, restore the default menu, (DEFAULT&SMARTBAR).
3
................................
Objectives
Define key triggers and their uses Program function keys Describe the characteristics of key triggers Classify key triggers Associate function keys with interface controls
Instructor Note
Topic Lecture Practice Total Timing 30 minutes 30 minutes 60 minutes
Introduction ......................................................................................................................................................
Introduction
Overview Form Builder enables you to redefine the actions of function keys. This lesson shows you how to create key triggers to either intercept, or supplement, the usual function key behavior with which your users navigate the Oracle Forms Developer application. Objectives After completing this lesson, you should be able to do the following: Define key triggers and their uses Program function keys Classify key triggers Associate function keys with interface controls
Key Triggers
What is a key trigger? Example: Using Key-Exit, display an alert and exit the application if the user selects the Yes button.
SET_ALERT_PROPERTY(question_alert, ALERT_MESSAGE_TEXT, SET_ALERT_PROPERTY(question_alert, ALERT_MESSAGE_TEXT, Do you really want to leave the form? ); Do you really want to leave the form? ); IF SHOW_ALERT(question_alert) = ALERT_BUTTON1 THEN IF SHOW_ALERT(question_alert) = ALERT_BUTTON1 THEN EXIT_FORM; -- default functionality EXIT_FORM; -- default functionality END IF; END IF;
Key Triggers
If you press a function key, Forms usually performs the default function associated with that key. You can modify the standard functionality of a function key by defining a key trigger for that function key. What Is a Key Trigger? A key trigger, like any other trigger, is a subprogram that is executed when a certain event occurs. In the case of a key trigger, the event is pressing the function key for which the trigger is defined. The trigger is usually named after the event that causes it to fire. When the key trigger is defined for a function key, the usual functionality of the key is replaced by the PL/SQL text of the trigger. In this respect, key triggers resemble on triggers. Example The form level Key-Exit trigger below displays an alert asking the end user if he or she wants to leave the form.
SET_ALERT_PROPERTY(question_alert, ALERT_MESSAGE_TEXT, Do you really want to leave the form?); IF SHOW_ALERT(question_alert) = ALERT_BUTTON1 THEN EXIT_FORM; -- default functionality END IF;
Note: If you also want to execute the default functionality of the function key, you must ensure that the key trigger includes the built-in function associated with the key. Example The following form-level Key-Menu trigger disables [Block Menu] for a form.
BEGIN NULL; END;
Instructor Note Demonstration: Use Orders2.fmb to demonstrate changing properties for the Key-Duprec trigger at the form level.
You cannot redefine all function keys with key triggers. Key triggers are defined at all three levels. A key trigger can contain SELECT statements and all built-ins. Key triggers can fire in Enter Query mode.
Function key triggers Key-Fn triggers and Oracle Terminal Key-Others triggers Key mapping for web deployed forms is different to Client Server
Technical Note The function keys Fn do not necessarily map to F1, F2, F3, and so on.
Key-Others trigger
Key Mapping Key mapping is defined by a platform specific resource file. The key definition file for the Microsoft Windows platform is FRMUSW.RES. You should use Oracle Terminal to edit Client Server resource files. For Web applications, you can edit the Java resource file, FRMWEB.RES, with any suitable operating system editor.
Technical Note Since mouse-event key triggers are not executed when the mouse is used to initiate window interaction, you should not place code that needs to be executed every time the window interaction occurs in a mouse-event key trigger. Instructor Note Demonstration: Use Orders2.fmb to demonstrate preventing duplication of the primary key by using the Key-Duprec trigger. Use the same demonstration to illustrate a call of a customized list of values (LOV) form instead of the native Forms LOV, using Key-Listval. To do this, click the product LOV button. Do not explain in detail the code associated with this button; it is covered in a later lesson.
What Are Mouse-Event Key Triggers? Mouse-event key triggers are function key triggers whose associated default functionality can also be activated directly with the mouse. Examples The Key-Nxtblk trigger is a mouse-event key trigger, because the NEXT_BLOCK functionality can also be activated using the mouse by clicking in the next block. In this case, a possible Key-Nxtblk trigger will not fire. The Key-Exeqry trigger is not a mouse-event key trigger, because the EXECUTE_QUERY functionality cannot be activated by simply clicking the mouse. It can be activated by the mouse only if a trigger is defined that fires as a result of the mouse action.
Adjust user interface Disable a (set of) function keys Replace or extend functionality of function keys Add additional function keys Be careful with Key-Others Do not use for validation
Call an LOV form Check for detail records before deleting a master record Prevent duplication of the primary key Adjust toolbar buttons for Enter Query mode
Instructor Note Demonstration: Use Orders2.fmb to demonstrate code for the CONTROL.EXIT_BUTTON button. Also show the Key-Exit trigger at form level.
Example Exit a Form by clicking [Exit Form] or an Exit button, or by choosing a menu item. 1 Define a Key-Exit trigger at form level. 2 Call DO_KEY by using: a The When-Button-Pressed trigger on the associated Exit button b The menu-item code for the menu item that exits the form using DO_KEY(EXIT_FORM); Interface Control Descriptions If the same functionality is activated by various interface controls, you should also make sure that the controls have the same descriptions.
Interface Control Function key Menu item Button Mouse event Property for Description Show keys description Menu-item label Button label Not applicable Changeable at Run Time? No Yes Yes Not applicable
Summary
Define key triggers in order to enhance keyboard functionality replace keyboard key
Provide consistant functionality between Function keys, buttons, menu items, and mouse events Display text in Keyboard Help Define Key-Fn, Key-Others, and mouse-event key triggers
Summary ......................................................................................................................................................
Summary
Understanding Key Triggers They fire when the associated function key is pressed. They are defined like any other trigger. Special properties are Display in Keyboard Help and Keyboard Help Text. Classification of Key Triggers Function key triggers Key-Fn triggers Key-Others Mouse-event key triggers Uses of Key Triggers Disable function keys Replace or extend default behavior of function keys Add function keys using Key-Fn triggers Adjust set of function keys using Key-Others Association with Other Interface Controls Function keys, buttons, menu items, mouse events Keys description, button label, menu-item label
Practice 3 Overview
Enforcing consistant form run time functionality by redefining [Exit Form] Changing the behavior of function keys by replacing [Enter Query] with a custom query form
Instructor Note The practices include the use of CALL_FORM. Explain to the students that is an alternative to OPEN_FORM, and will be covered in a later lesson.
Practice 3
1 Maintain consistent functionality in your form module by using key
triggers. Define a key trigger in your ORDERS form to give users consistent functionality whenever they exit the form, either using the menu or when the CONTROL.EXIT_BUTTON button is pressed. a Redefine [Exit Form] in your ORDERS form so that an alert message is displayed to users before allowing them to exit the form. b Amend the entry in Keyboard Help to Exit Orders for the key trigger. c Save and compile your form. Deploy your form to the Web to test. d Customize the Alert Text message in your key trigger and ensure that it is displayed whenever the user exits the form using the EXIT_BUTTON on the Control block. e Save and compile your form module. Deploy to the Web and test your form. If you have time 2 Disable [Enter query] in your CUSTOMERS form by creating an appropriate key trigger. Replace [Enter Query] functionality with a call to the customized query form CUSTQUERY. This form allows the user to select a CUSTOMER ID, a CUSTOMER NAME, or a SALES REP ID. The user selections are returned to your CUSTOMER form using global variables. a Add the following code to your key trigger:
call_form('custquery',no_hide); execute_query; b
The CUSTQUERY form will return three values, held in global variables. The contents should be passed to your CUSTOMERS form to allow the user to execute a restricted query. Use the following global variables:
:global.custid; :global.custname; :global.repid;
Define the global variables in your CUSTOMERS form to ensure that the user can perform unrestricted queries. d Save and compile your CUSTOMER form. Deploy your form to the Web to test.
4
................................
Objectives
Define mouse events Cause a form module to respond to mouse movement Cause a form module to respond to mouse button actions
Instructor Note
Topic Lecture Practice Total Timing 30 minutes 20 minutes 50 minutes
Introduction ......................................................................................................................................................
Introduction
Overview The keyboard, menu, and mouse are the operators tools for interacting with the Forms application. This lesson demonstrates how to write an application that responds to mouse events. Objectives After completing this lesson, you should be able to do the following: Define mouse events Cause a form module to respond to mouse movement Cause a form module to respond to mouse button actions
Mouse Events
Point at which processing can be influenced Identified by: Mouse movement Mouse button action
GUI-specific arrow symbol GUI-specific busy symbol GUI-specific crosshair symbol GUI-specific help symbol GUI-specific insertion symbol
Instructor Note Use mousecursor.fmb to demonstrate the mouse cursor styles. Remind delegates to return the cursor style to DEFAULT after trigger failure.
The valid settings for the cursor style property are: BUSY CROSSHAIR DEFAULT HELP INSERTION
When-Mouse-Enter
When-Mouse-Leave
When-Mouse-Move
Instructor Note Mouse movement and button trigger functionality in Web-deployed forms can be provided by creating appropriate JavaBeans. Deployment of these JavaBeans is covered in a later lesson; for the creation of JavaBeans, students should be referred to an appropriate Java tool, such as Oracle JDeveloper. Demonstration: Use mousewinner.fmb to demonstrate the operation of the WhenMouse-Enter trigger. Use mousevariables.fmb to demonstrate all the mouse triggers and system variables.
Uses of the Mouse Movement Triggers Use When-Mouse-Move in conjunction with the SYSTEM.MOUSE_X_POS and SYSTEM.MOUSE_Y_POS system variables to return the exact position of the mouse within an item. Use When-Mouse-Leave to update an item value without causing the cursor to navigate out of the current item Web Design Tip If you define mouse movement triggers in client server applications, the performance of your form may be adversely affected. This is because these triggers have the potential to fire frequently. For this reason, you should use them sparingly; in Web-deployed forms these triggers are disabled.
7 6
3 4 5
1 2 3 4
5 6 7
Technical Note The SYSTEM.MOUSE_FORM system variable is NULL if the platform is not a GUI platform. Instructor Note Demonstration: Use mousevariables.fmb to demonstrate all the mouse triggers and system variables.
The Mouse Position System Variables Use the following system variables to determine when the mouse has moved, where it has moved from, and where it has moved to.
Variable SYSTEM.MOUSE_FORM Use Identifies the form module that the mouse is currently in SYSTEM.MOUSE_CANVAS Identifies the canvas that the mouse is currently on SYSTEM.MOUSE_ITEM Identifies the item that the mouse is currently in SYSTEM.MOUSE_RECORD Identifies the record number that the mouse is currently in SYSTEM.MOUSE_RECORD_OFFSET Identifies the number of the record that the mouse is currently in, relative to the first visible record; uses a 1-based index SYSTEM.MOUSE_X_POS Identifies the x coordinate of the mouses current position (If the mouse is positioned on a canvas, the x coordinate is measured relative to the top left corner of the canvas. If the mouse is in an item, the x coordinate is measured relative to the top left corner of the item.) SYSTEM.MOUSE_Y_POS Identifies the y coordinate of the mouses current position (If the mouse is positioned on a canvas, the y coordinate is measured relative to the top left corner of the canvas. If the mouse is in an item, the y coordinate is measured relative to the top left corner of the item.)
When-Mouse-Up
When-Mouse-Click click
Technical Note Click and double-click work only if the mouse stays on the item (or canvas) throughout the down-up action.
When-Mouse-Up
When-Mouse-Click When-Mouse-Doubleclick
Firing Sequence for Mouse Button Action Triggers When you double-click an item or canvas, you are potentially causing the following triggers to fire in the order in which they are listed. Similarly, when you click an item or canvas, the triggers that precede the When-Mouse-Click trigger will fire. When-Mouse-Down When-Mouse-Up When-Mouse-Click When-Mouse-Down When-Mouse-Up When-Mouse-Doubleclick Web Design Tip When any mouse button action is initiated in a Web-deployed form, the Java user interface refers to the Forms Server to identify the appropriate mouse button trigger. Even though you may not have defined the relevant mouse button trigger, the user interface will generate this event if you have defined at least one mouse button trigger in your form. You should therefore restrict use of mouse button triggers.
SYSTEM.MOUSE_BUTTON_PRESSED
SYSTEM.MOUSE_BUTTON_MODIFIERS
Ctrl
Alt
Instructor Note Use mouse.fmb to demonstrate all mouse triggers and system variables.
The Mouse Button System Variables Use the following system variables to determine which mouse button was pressed and which special key, if any, was used.
Variable SYSTEM.MOUSE_BUTTON_PRESSED Use Identifies which mouse button was pressed (values of 13, where 1 is the left mouse button) Identifies which special key was pressed to modify the usual mouse button action
SYSTEM.MOUSE_BUTTON_MODIFIERS
(possible values are Shift+, Caps Lock+, Control+, Alt+, Command+, Super+, and Hyper+) If the operator holds down the [Ctrl] and [Shift] keys while pressing the mouse button, SYSTEM.MOUSE_BUTTON_MODIFIERS contains the value Shift+Control+.
Summary
Respond to mouse movement Mouse position system variables Mouse movement triggers
Respond to mouse button actions Mouse button system variables Mouse button triggers
Summary ......................................................................................................................................................
Summary
In this lesson, you saw how to write an application that responds to mouse events. Mouse Events Entry to a canvas or an item Exit from a canvas or an item Move the cursor Click Double-click Up Down Responding to mouse movement Mouse position system variables Mouse Movement Triggers When-Mouse-Enter When-Mouse-Leave When-Mouse-Move Responding to Mouse Button Actions Mouse button system variables Mouse button triggers - When-Mouse-Click - When-Mouse-Doubleclick - When-Mouse-Up - When-Mouse-Down
Practice 4 Overview
Invoke an editor when the operator double-clicks an item Redefine the mouse cursor style according to context
Practice 4
In this practice, you provide additional functionality in your forms by defining mouse event triggers.
1 In your CUSTOMERS form, define a mouse event trigger on
S_CUSTOMER.COMMENTS that invokes the items editor when the user double-clicks the item.
2 In your ORDERS form change the mouse cursor symbol to busy while
the HELP canvas is displayed. a Ensure that the default symbol is restored whenever the user hides the HELP canvas. b The user can close the HELP canvas without pressing the HIDEHELP button, by navigating to an item in another block. How can you ensure that the mouse cursor is always restored? c Save and compile your form modules. Deploy your forms to the Web to test.You can call the ORDERS form from your CUSTOMERS form.
5
................................
Objectives
Display a form document in multiple windows Write code to interact with windows Manipulate windows programmatically Manipulate canvas views programmatically Control windows and canvases with Web-deployed forms Display large data blocks in a window
Instructor Note
Topic Lecture Practice Total Timing 45 minutes 35 minutes 80 minutes
Introduction ......................................................................................................................................................
Introduction
Overview You should already be familiar with setting window and canvas properties at design time. This lesson covers the triggers and built-ins that you can use to manage the properties and behavior of windows and canvases at run time. Objectives After completing this lesson, you should be able to do the following: Display a form module in multiple windows Write code to interact with windows Manipulate windows programmatically Manipulate canvas views programmatically Control windows and canvases with Web-deployed forms Display large data blocks in a window
When-Window-Deactivated Deactivates a window When-Window-Closed When-Window-Resized Closes a window Maintains visual standards
Keeping Track of the Triggered Window The SYSTEM.EVENT_WINDOW system variable contains the name of the last window for which a window-interaction trigger fired. You can use this system variable to perform different actions for different windows in your window-interaction triggers. Note: Help with triggers is available by pressing [Ctrl] + [H] and selecting PL/SQL Reference - Triggers.
Technical Note In Microsoft Windows, you can reference the multiple document interface (MDI) application window with the FORMS_MDI_WINDOW constant. FORMS_MDI_WINDOW is used with certain built-in functions and procedures that relate to windows. In Web-deployed forms, you can obtain similar functionality by setting the Forms Applet WIDTH and HEIGHT parameters in the base HTML page. Definition of these Form Applet parameters is covered later in this course.
Technical Note REPLACE_CONTENT_VIEW does not hide the stacked canvas already displayed in the window. In contrast SHOW_VIEW and SET_VIEW_PROPERTY will display the given canvas in front of any stacked canvas, if the canvas Visible property is set to true. Instructor Note Point out that the GET_ built-ins are the most important ones when writing generic code. Use tab_page.fmb to demonstrate: The tab canvas system variables. Click any tab page How to enforce navigation when a user selects a tab page Clicking the TopMost Tab Page button to illustrate the TOPMOST_TAB_PAGE argument You can run this demonstration on the Web from winmenu.fmb.
Uses either function key Next tab Page Previous Tab page Previous Next Tab Page Tab Page
:SYSTEM.TAB_NEW_PAGE :SYSTEM.TAB_PREVIOUS_PAGE
Instructor Note The When-Tab-Page-Changed trigger does not fire if the end user presses [Next Item] + [Tab] to navigate from one field to another in the same block but on different tab pages.
Instructor Note TOPMOST_TAB_PAGE returns only the tab page name, and not the canvas name. To set a property, you must concatenate the canvas name with the page name.
GET_TAB_PAGE_PROPERTY
SET_TAB_PAGE_PROPERTY
Note: The tab page is named using the syntax CanvasName.PageName. Example
DECLARE tp_id Tab_Page; BEGIN tp_id := Find_Tab_Page(Canvas2.TabPage1); IF Get_Tab_Page_Property(tp_id, enabled) =FALSE THEN Set_Tab_Page_Property(tp_id, enabled, property_true); END IF; END;
Other Arguments for Canvas Built-Ins If you want to make a tab page the top-most on its underlying tab canvas, you can use the built-in procedure SET_CANVAS_PROPERTY and set the canvas property TOPMOST_TAB_PAGE. You can also get the top-most tab page by using the built-in function GET_CANVAS_PROPERTY.
GET_CANVAS_PROPERTY(canvas_name, TOPMOST_TAB_PAGE) SET_CANVAS_PROPERTY(canvas_name, TOPMOST_TAB_PAGE, page_name)
In the preceding syntax example, page_name is either a constant, in single quotes, or a variable.
Block 3
Cursor location
Technical Note You can also maximize the client server MDI window application with the WINDOW_STATE command line parameter:
ifrun60.exe module=customer.fmx userid=my_name/my_password@my_database window_state=maximize
You can switch from the MDI to the SDI window application by using the USESDI command line parameter:
ifrun60.exe module=customer.fmx userid=my_name/my_password@my_database usesdi=yes
With SDI window applications, you must size form module windows to allow for the menu, menu toolbar and console bar to be displayed. Instructor Note Demonstration: Use window.fmb to demonstrate the two examples described above. Show the When-New-Form-Instance trigger, which includes the code for maximizing the MDI application window. Show the GET_CURSOR_WINDOW program unit.
Locating the Cursor Window The cursor may be located in a nonactive window. In this case, you can use the following GET_CURSOR_WINDOW function to find this window.
FUNCTION get_cursor_window RETURN VARCHAR2 IS BEGIN RETURN (GET_VIEW_PROPERTY(GET_ITEM_PROPERTY( NAME_IN(system.cursor_item),item_canvas), window_name)); END;
Instructor Note Demonstration: Use window.fmb to demonstrate to the Close option from either the Microsoft or Java Windows System menu.
Closing Windows
Use the Microsoft Windows close button, or system-menu box, to provide the user with a means for closing windows. There is no default behavior in Forms when a user clicks on the close button, therefore you must define a When-Window-Closed trigger. The following examples show a form based on departments and employees. The department block and the employee block are located in separate windows. The form level triggers When-Window-Closed and When-Window-Activated implement the following functionality: Exiting from the form or hiding the window that is closed by the user (Forms automatically activates another window.) Forcing navigation in the newly activated window Note: The function GET_CURSOR_WINDOW, discussed in an earlier example, is used here. The When-Window-Closed Trigger at Form Level
BEGIN IF :SYSTEM.EVENT_WINDOW = WINDOW1 THEN DO_KEY(exit_form); ELSIF :SYSTEM.EVENT_WINDOW = WINDOW2 THEN HIDE_WINDOW(window2); END IF; END;
The base HTML file is downloaded when a user requests your forms application from the Web server. It contains information that would otherwise be supplied with the client server RUNFORM command. Information on building the base HTML file is covered in the course Oracle Forms Server: Deploy Internet Applications.
usesdi=yes separateFrame=true
If your form module canvases must be larger than the Applet window, then you should either specify window scrollbars, or consider other Form Builder features such as Tab canvases, Tree objects, and scrollable Stacked canvases. With these you can extend the available canvas area within a form module without creating large canvases.
Instructor Note Use largeform.fmb to demonstrate the implementation of stacked canvases for large records. Use custwiz.fmb to demonstrate the implementation of wizards for large records. The building of wizards is covered in a later lesson. Use summitcust.fmb to demonstrate the implementation of hierarchical tree items and tab canvases for large records.
Form Module images are specified within the form Image Items Boilerplate Images
splashScreen backGround
Identifies the file containing image to be displayed Identifies the file containing image background
Web Design Tip Minimize the use of background objects on your canvases. There is an overhead in downloading images, boilerplate text, and graphics, which can adversely affect performance in Web-deployed forms. Therefore you should try to: Use the Prompt item property instead of boilerplate text. Define only common boilerplate graphics such as rectangles and lines. For further information on the performance of Web-deployed forms, see the course Oracle Forms Server: Deploy Internet Applications.
Summary
Summary
Relate Windows to Data Blocks Multiple blocks correspond to multiple windows. Window activation does not induce navigation. Transaction management is block-oriented.
Manage Windows in Web-deployed forms MDI and SDI windows Sizing the Applet area Managing Images
Summary ......................................................................................................................................................
Summary
Window-Interaction Triggers When-Window-Activated When-Window-Deactivated When-Window-Closed When-Window-Resized Use the SYSTEM.EVENT_WINDOW system variable to keep track of the triggered window. Built-ins for Manipulating Windows Manipulating Windows Manipulating Canvases Manipulating Views Windows and Blocks Windows may contain multiple blocks and blocks may be located on several windows. Forms will not automatically navigate to an item located in an activated window. Transaction management is block-oriented rather than window-oriented. Web-deployed Forms MDI and SDI windows Applet Areas Separate frames Display Large Data Blocks Splash Screens and Background Images
Practice 5 Overview
Building a multiple-window form Using window interaction triggers Using window and canvas-view built-ins
Enhancing the tab canvas functionality by Customizing tab page navigation Disabling tab pages
Practice 5
1 Manipulate a multiple-window form.
In your ORDERS form module, ensure that the form is exited when a user closes the Orders window using the window system menu box. An alert should be displayed to users asking them to confirm that they wish to leave the application. b If a user closes the Inventory window through the system menu box, ensure that the form remains open with the cursor positioned in the Orders window. c Whenever the user navigates between the Order and Inventory windows, place the cursor in the first navigable item within the current window. d Save and compile your form. Deploy your form to the Web to test.
a 2 In your CUSTOMERS form module, define triggers to manage tab page
navigation. a Using an appropriate trigger, disable the COMMENTS tab page whenever the COMMENTS item contains no text. b The trigger should fire whenever the user navigates to another record. c Whenever the user moves from one tab page to another, ensure that the mouse cursor is placed in the first navigable field within the page. d Save and compile your form. Deploy your form to the Web to test. If you have time 3 How can you ensure that the user is returned to the first navigable item within a tab page after navigating from the last navigable item?
4 How can you enforce item navigation dynamically within a tab page?
6
................................
Objectives
Describe the various data source types Base a data block on a FROM clause query Describe the advantages of using a FROM clause query
Objectives
Base a data block on a stored procedure Return a REF cursor from a stored procedure Return a table of records from a stored procedure Select the appropriate data source for a data block
Instructor Note
Topic Lecture Practice Total Timing 40 minutes 30 minutes 70 minutes
Introduction ......................................................................................................................................................
Introduction
Overview This lesson introduces you to the different data source types that can be used for data blocks. This lesson also provides you with some guidelines for choosing the best data source for the job. Objectives After completing this lesson, you should be able to do the following: Describe the various data source types Base a data block on a FROM clause query Discuss the advantages of using a FROM clause query Base a data block on a stored procedure that returns a REF cursor Select the appropriate data source for a data block
Query
DML
Table FROM clause query Stored procedure Transactional trigger Company Name: Company Code: Balance:
Table
Perform joins, lookups, and calculations on the server (thus avoiding multiple network trips) without having to define a view every time
Improves developer productivity Reduces the burden on the DBA Improves performance
Instructor Note Demonstration: Run the from_clause.sql and from_clause3.sql scripts to illustrate a FROM clause query.
Why Use a FROM Clause Query? FROM clause queries are used to perform: Joins Lookups Calculations This is done without having to create a view on the server. FROM clauses queries can also be used to prototype views and to increase performance. Using a FROM clause query as a block data source is similar to using a view based on an updatable join as a block data source. However, a FROM clause query provides you with more control, because the presence of a DBA is not required to define the view. Note: The FROM clause query produces results that are identical to an updatable join-view from the client side, but for which there is no defined view on the server.
Querying Ename Jones Smith Adams Clark Job Clerk Clerk Clerk Clerk Hire date 01-Jan-95 01-Jan-95 01-Jan-95 01-Jan-95
Data block
Company Name: Company Company Code: Company Name: Code: Balance: Balance:
Updating Ename Jones Smith Adams Clark Job Clerk Clerk Clerk Clerk Hire date 01-Jan-95 01-Jan-95 01-Jan-95 01-Jan-95
Data block
Company Name: Company Company Code: Company Name: Code: Balance: Balance:
The objects returned by the REF cursor The REF cursor The query procedure: Data returned through the first argument (IN OUT)
Define a package body: Write the code for the query procedure
Instructor Note Demonstration: Edit the RefCurSpec.sql and RefCurBody.sql scripts to show the code of a stored procedure using a REF cursor.
The structure of each row of the table The table of records The query procedure: Data returned through the first argument (IN OUT)
Define a package body: Write the code for the query procedure
Instructor Note Demonstration: Edit the TorQuerySpec.sql and TorQueryBody.sql scripts to show the code of a stored procedure using a table of records.
The structure of each row of the table The table of records A procedure to insert rows A procedure to update rows A procedure to delete rows A procedure to lock rows
Define a package body by writing the code for each DML procedure
Note See Appendix F, Handling Server-Side Errors for code details. Instructor Note Demonstration: Edit the TorDMLSpec.sql and TorDMLBody.sql scripts to demonstrate the code for a table of records in a stored procedure.
REF cursor
REF cursor
3
Fetched rows
Cursor
Cursor
3
Table of records
Data source type Query procedure Insert procedure Update procedure Delete procedure Lock procedure
Instructor Note Demonstration: If they do not already exist, create and populate the EMP and DEPT tables using the UTLSample.sql file. Run the TorDMLSpec.sql and TorDMLBody.sql scripts. Create a new form module. Base the block on a stored procedure. The query procedure is emp_pkg.empquery. The insert procedure is emp_pkg.empinsert. The update procedure is emp_pkg.empupdate. The delete procedure is emp_pkg.empdelete. The lock procedure is emp_pkg.emplock.
Instructor Note Demonstration: Use the form created previously to illustrate these properties.
Create a dynamic view Perform validation and DML on the server side
Increase control and security Specify a SELECT statement at run time Query or update multiple tables Perform complex computations Perform validation and DML on the server side
Instructor Note Demonstration: Use the Stored Procedures demonstration to illustrate how to use the same block to display data from different tables. Before the demonstration, run the OrderSpecs.sql and OrderBody.sql scripts.
Data Source Table View FROM Clause Proc-Ref Cur Proc-Table Rec Transac. Trigger
Data Source Type Restrictions When deciding on a data block source, consider your requirements: Will the block be used only to query records? Will the block be used to perform inserts, updates, and deletes? Will the block be used to perform both query and DML? To decide, you should also consider the functional restrictions for each data source type:
Data Source Table View FROM Clause Procedure Using a REF Cursor Procedure Using a Table of Records Transactional Trigger Allows Query Yes Yes Yes Yes Yes Yes Allows DML Yes Yes No No Yes Yes
Summary
Base data blocks on new data sources: FROM clause query (query only) Stored procedure (query and DML)
Exploit features of stored procedures : REF cursors limited to a single SELECT statement Table of records can be a complex procedure
Summary
Use the Data Block Wizard to specify: Data source type Procedures for queries, updates, deletes, and locking
Summary ......................................................................................................................................................
Summary
New Data Sources Stored procedure (query and DML) FROM clause query (query only) Stored Procedures Return REF cursorslimited to a single SELECT statement Table of recordscan be a complex procedure Using the Data Block Wizard Specify data source type Specify procedures for queries, updates, deletes, and locking
Practice 6 Overview
Creating a package containing a stored procedure to return a REF cursor Creating a data block based on a REF cursor stored procedure
Practice 6
1 Create a server-side package containing a procedure to return a REF
cursor. a Create the Orders_pkg package specification; you can import the code from the pr6_1.txt file. b Create the Orders_pkg package body; you can import the code from the pr6_2.txt file. c Examine the Orders_pkg package body to identify required parameter values.
2 Open the ORDERREFCURSOR.fmb file and save as ORDREFXX where
XX is your student course number. This form contains a control block, called CHOOSE, and a group of option buttons which allows the user to specify a parameter value to be passed to the REF cursor. a Create a data block called SELECTION and base it on the REF cursor procedure that you have just created. b Pass the name of the radio group as the value for the P_VIEW argument: :choose.view_type. c In the layout editor, customize the canvas layout to ensure that SELECTION items are displayed to the left of the option buttons group. d Save and compile your form. Deploy your form to the Web to test.
7
................................
Objectives
After completing this lesson, you should be able to: Recognize which object types are supported
Describe how object types are represented within Form Builder Create a block based on an object table Create a block based on a relation table with an object or an REF column Populate a REF column with an LOV
Instructor Note
Topic Lecture Practice Total Timing 30 minutes 25 minutes 55 minutes
Introduction ......................................................................................................................................................
Introduction
Overview This lesson reviews certain object features of Oracle8i and explains how these objects are displayed in the Object Navigator. Objectives After completing this lesson, you should be able to do the following: Recognize which Oracle8i object types are supported Describe how Oracle8i objects are represented within Form Builder Create a block based on an object table Create a block based on a relational table with an object column or REF column Populate a REF column with an LOV
Object Types
Attributes Ship
Check status
Cancel
Hold Methods
Instructor Note These pages review object type fundamentals. Additional object type information can be found in Appendix D, Introduction to Oracle8i Object Features.
Review of Objects
Review of Objects
With an object type, you can create object tables, object columns, object views, and INSTEAD-OF triggers. Object Tables After you have declared an object type, you can create objects based on the type. One way to do this is to create a table whose rows are objects of that object type. Rows in an object table are assigned object IDs (OIDs) and can be referenced using a REF type. Object Column Another construct that can be based on an object type is an object column in a relational table. In the object table, the rows of a table are objects. In a relational table with an object column, the column is an object. The table usually has standard columns, as well as one or more object columns. Object columns are not assigned OIDs, and thus cannot be referenced using object REF values. Object View An object view transforms the way a table appears to a user, without changing the actual structure of the table. Object views make relational tables look like object tables. Objects accessed through object views are assigned OIDs, and can be referenced using object REFs. INSTEAD OF Triggers INSTEAD OF triggers provide a transparent way of modifying views that cannot be modified directly through SQL DML statements (INSERT, UPDATE, and DELETE). These triggers are called INSTEAD-OF triggers because, unlike with other types of triggers, the Oracle server fires the trigger instead of executing the triggering statement. The trigger performs update, insert, or delete operations directly on the underlying tables. Technical Note The Database Trigger Editor includes the INSTEAD-OF triggering event.
References to Objects
Object REFs
When a row in an object table or object view is created, it is automatically assigned a unique identifier called an object ID (OID). This OID value can be stored in attributes of other objects, or columns of other tables. The stored copy of the OID then becomes a pointer, or REF, to the original object. (Object columns are not assigned OIDs and cannot be pointed to by a REF.) In relational databases, primary key values are used to identify records uniquely. In object-relational databases, OIDs provide an alternate method. With relational tables, you can associate two records by storing the primary key of one record in one of the columns (the foreign key column) of another. In a similar way, you can associate two objects by storing the OID of one object in an attribute of another. Or you can associate a row in a relational table to an object by storing the OID of an object in a column of a relational table. The attribute or column that holds the OID is of data type REF. Remember, the object itself is not stored in the table, only the OID value for the object.
Large Objects: BLOB, CLOB, NCLOB, BFILE User-defined objects Object table Column object REF column
Object_A Attr_A1
Object Display
Object REF
Object Type
-- object table
manager_id
In the diagram, the wizard shows all the columns of the object table OO_DEPT_TABLE (ID, NAME, REGION_ID). Select any or all as data block items.
In the diagram, the wizard displays ID, NAME, and REGION_ID as columns you can select as data block items.
As seen in the diagram, the REF column name (DEPT_ID) appears twice in the column selection list. It appears once as a heading for the referenced objects attributes and then again as a pointer. The column is selectable.
Select REF attribute columns: This causes the columns to appear as data items at run-time. Select the REF item itself:
This causes the item to be placed on a Null canvas. The item does not appear at run time. The item is available for coding purposes.
Summary
Identify supported Oracle8i object types Define data blocks based on object tables Define data blocks based on tables with object columns or REF columns Populate REF columns with an LOV
Summary ......................................................................................................................................................
Summary
Oracle Forms Developer supports most, but not all, of the Oracle8i object types. In Forms Builder, object types are displayed like columns, where indentation shows the nesting of objects. Blocks can be based on object tables. Blocks based on object or relational tables can include object columns or REF columns. REF columns can be populated with an LOV.
Practice 7 Overview
Creating a block based on a relational table with an object column Creating a block based on a relational table with a REF column Populating a REF column with an LOV
Practice 7
1 Create a data block based on a relational table with an object column. a b c d e
Create a form called OBJ_COLXX where XX is your student course number. Using the Data Block Wizard, create a block based on the REL_EMP_TABLE_OBJCOL relational table. Select the columns ID, FIRST_NAME, and LAST_NAME. Expand the object column DEPT_ID and select the attributes ID and NAME. Note the names that are given to the new items. In the Layout Wizard, select all available items for display. Change the prompt for item DEPT_ID to Department ID and DEPT_ID_NAME to Department Name. Use a form layout. Save, compile, and test your form.
If you have time 2 Create a block based on a relational table with an REF column, and specify an LOV to populate the REF column. a Create a form called REF_COLXX where XX is your student course number. b Create a block based on the REL_EMP_TABLE_REFCOL relational table. c Select the columns ID, FIRST_NAME, and LAST_NAME. d Select the DEPT_ID attributes ID and NAME. e Create an LOV for the REF item DEPT_ID. Select the check box, and select OO_DEPT_TABLE as the source for the LOV. f In the Layout Wizard, select all available items for display. g In the Object Navigator, identify the canvas with which item DEPT_ID is associated. h In the Object Navigator, check that an LOV and associated record group have been created. i Save, compile, and test the form.
8
................................
Objectives
Define block coordination Coordinate data blocks by using REF relations Describe the characteristics and principles of relation-handling code Implement a coordination-type toggle Force one commit per master record
Instructor Note
Topic Lecture Practice Total Timing 25 minutes 25 minutes 50 minutes
Introduction ......................................................................................................................................................
Introduction
Overview You have seen how form modules consist of data blocks based on related tables. This lesson shows how you can modify the relationship between two data blocks to affect the way in which deletes are handled and to what extent the data blocks are coordinated at query time. Also, it explains how to create relationships based on object REFs. Objectives After completing this lesson, you should be able to do the following: Define block coordination Coordinate data blocks by using REF relations Describe the characteristics and principles of relation-handling code Implement a coordination-type toggle Force one commit per master record
Relations
Logical objects that handle the relationship between two blocks Created implicitly with a master-detail form module Created explicitly with the New Relation dialog box
Instructor Note Demonstration: Use Orders3.fmb to demonstrate how to create explicitly a relation between the S_ITEM and S_INVENTORY blocks.
Creating a Relation
What Is a Relation? A relation is a Form Builder object that handles the relationship between two associated blocks. You can create a relation either: Implicitly with a master-detail form module Explicitly in the Object Navigator Implicit Relations When you create a master-detail form module, a relation is automatically created. This relation is named in the format masterblock_detailblock, for example, S_ORD_S_ITEM. Explicit Relations If a relation is not established when default blocks are created, you can create your own, either by setting the properties in the master block New Relation dialog box, or by calling the reentrant wizard for the detail data block. Like implicitly created relations, PL/SQL program units and triggers are created automatically when you explicitly create a relation. Instructor Note The creation of explicit relations was covered in the Oracle Forms Developer: Build Internet Applications I course. Use these pages to review the fact that relations can be created implicitly or explicitly.
Block Coordination
Coordination-causing event Block-coordination phases: Clear phase executed before change of master record Populate phase executed after change of master record
Implementation of block coordination: The Copy Value from Item property Relation-handling triggers Relation-handling procedures
Instructor Note Explain to students the importance of the Copy Value from Item property for implementing block coordination. Demonstration: Use Orders3.fmb to demonstrate the objects used to implement a block coordination.
Block Coordination
To maintain a master-detail relationship, Forms coordinates the master and detail blocks to ensure that only the detail records that belong to the current master record are displayed. Coordination-Causing Events Any event that changes the master record is called a coordination-causing event or a coordination operation. Forms automatically coordinates the master and detail blocks again when you move to another master record. Block Coordination Phases
Phase Clear Description Forms clears all detail blocks before it navigates to the new master record. Unsaved changes in detail blocks are deleted. If the Clear phase fails, Forms stops coordination processing and does not navigate to the new master record. Forms queries all detail blocks after it has navigated to the new master record, unless the coordination type is Deferred.
Populate
Implementation of Block Coordination Forms implements block coordination through the following elements: The Copy Value from Item property on the foreign-key item in the detail block, which specifies the corresponding primary-key item in the master block Relation-handling triggers, which fire during the Clear and Populate phases of block coordination Relation-handling procedures, which are called from relation-handling triggers Note: The elements above are controlled through the relation object. Web Design Tip You can reduce potential network traffic within Web-deployed forms by specifying deferred coordination. By using relation-handling built-ins, users can be given the run-time option of selecting either immediate or deferred coordination.
Technical Note Relation-handling triggers fire only if you have defined a corresponding relation.
On-Populate-Details
On-Check-Delete-Master
Note: If you specify a cascade-delete foreign-key rule for a relation, Form Builder uses a Pre-Delete trigger to implement this rule. However, this is a commit trigger, not a relation-handling trigger, and can also be used outside the context of relations.
CLEAR_ALL_MASTER_DETAILS QUERY_MASTER_DETAILS CHECK_PACKAGE_FAILURE Forms adds comments around code. You add your own code before or after these comments.
Note: The CLEAR_ALL_MASTER_DETAILS procedure gives you an example of how to walk recursively through a hierarchical tree of blocks. Adding Your Own Code to Relation-Handling Triggers Forms adds comments around the PL/SQL code that it generates for relation handling, for example:
--- Begin default relation program section -BEGIN CLEAR_ALL_MASTER_DETAILS; END; --- End default relation program section --
You can add PL/SQL code to relation-handling triggers before the Begin default relation program section comment or after the End default relation program section comment. Note: Forms will not delete a relation-handling trigger to which you have properly added PL/SQL code.
Technical Note You can use these system variables in the On-Clear-Details trigger only. Assign their values to global variables to broaden the scope.
GET_RELATION_PROPERTY
(*): You can also set those properties using the Set-Relation-Property builtin.
Use GET_BLOCK_PROPERTY to obtain relation name. Use GET_RELATION_PROPERTY to obtain current coordination type. Use SET_RELATION_PROPERTY to switch to other coordination type.
Instructor Note Demonstration: Use Orders3.fmb to demonstrate the CoordinationType Toggle. Select Query>Deferred.
Updates the commit status by performing validation Checks the commit status of the master record Raises FORM_TRIGGER_FAILURE in case of changes
In the On-Clear-Details trigger Before the Begin default relation program section comment
Summary
Define Relation coordination properties Manage data block coordination Coordination-causing events change the master record Clear and populate
Summary
Obtain relation-handling information Identify characteristics of relation-handling triggers Identify characteristics of relation-handling procedures
Summary ......................................................................................................................................................
Summary
Creating Relations Implicitly, when you create a master-detail form module. Explicitly, by creating the relation after the blocks have been created. Block Coordination Coordination-causing events cause a change of the master record. The two block-coordination phases are the Clear and Populate phases. Base coordination of blocks on REF values. Elements Involved in the Implementation of Block Coordination The Copy Value from Item property Relation-handling triggers and procedures Characteristics of Relation-Handling Triggers On-Clear-Details implements the Clear phase. On-Populate-Details implements the Populate phase. On-Check-Delete-Master implements restricted-delete rules. Principles of Relation-Handling Code The three relation-handling procedures are CLEAR_ALL_MASTER_DETAILS, QUERY_MASTER_DETAILS, and CHECK_PACKAGE_FAILURE. Add your own code to relation-handling triggers before or after comments generated by Forms. Obtaining Relation-Handling Information There are two system variables for relation handling. Built-ins for relation handling can be used to get relation names and to get or set relation properties.
Practice 8 Overview
Examining and changing relation properties Implementing a coordination-type toggle for a master-detail form Synchronize coordination-type toggle at form startup
Practice 8
1 Open your ORDERS form and examine the properties of the relation
called S_ORD_S_ITEM. a Note the deletion and coordination property values. b Run the ORDERS form and test the way deletes are handled. 2 Implement a query coordination-type toggle. a Add two check boxes to the control block with the following properties:
Property Name Enabled Label Value When Checked Value When Unchecked Check Box Mapping of Other Value Keyboard Navigable Mouse Navigate Data Type Initial Value DataBase Item Canvas b Check Box 1 IMMEDIATE Yes Immediate Y N CHECKED No No CHAR Y No TOOLBAR Check Box 2 AUTO_QUERY No Auto Query Y N UNCHECKED No No CHAR Y No TOOLBAR
Use the Layout Editor to position the check boxes appropriately in the Toolbar canvas. c Make sure that the first check box enables a user to toggle between immediate coordination and deferred coordination. You can import the code from the pr8_1.txt file. d Make sure that the second check box enables a user to toggle between automatic query and no automatic query for the detail block. This check box should be disabled if the other check box indicates immediate coordination. You can import the code from the pr8_2.txt file. e Save, compile, and test your form.
Practice 8 ......................................................................................................................................................
If you have time 3 Synchronize the check boxes at form startup. a Open your ORDERS form module b Create a procedure called SYNCHRONIZE_CHECKBOX. This procedure synchronizes the IMMEDIATE and AUTO_QUERY check boxes with the current default value. You can import the code from the pr8_3.txt file. c Call this procedure from the When-New-Form-Instance trigger. d Save, compile, and test your module.
9
................................
Objectives
Describe the different ways of invoking additional forms Open, call, and close forms Navigate between Web-deployed form modules
Objectives
Control opened forms and called forms Manage transaction processing for opened forms and called forms Choose the most appropriate method for invoking forms Pass form parameters
Instructor Note
Topic Lecture Practice Total Timing 45 minutes 45 minutes 90 minutes
Introduction ......................................................................................................................................................
Introduction
Overview You have already seen that Oracle Forms Developer applications frequently consist of more than one form. This lesson revisits the topic of multiple form applications and takes a deeper look into the ways in which one form module can invoke another and the effects this has on transaction processing. Objectives After completing this lesson, you should be able to do the following: Describe the various ways of invoking additional form modules Open, call, and close form modules Navigate between Web-deployed form modules Control open form modules and called form modules Manage transaction processing for open and called form modules. Choose the most appropriate method for invoking form modules Pass form parameters
OPEN_FORM(form_name, activate_mode, OPEN_FORM(form_name, activate_mode, session_mode, data_mode, paramlist); session_mode, data_mode, paramlist);
Characteristics of OPEN_FORM
Restricted Not valid in Enter Query mode No savepoint issued Modeless with respect to other opened forms Session run time option: FORMS60_SESSION
Instructor Note Explain that different transaction scopes refers to the SESSION/NO_SESSION parameter of the OPEN_FORM built-in.
Description The file holding the executable module Either ACTIVATE (the default) or NO_ACTIVATE Either NO_SESSION (the default) or SESSION Either NO_SHARE_LIBRARY_DATA (the default) or SHARE_LIBRARY_DATA Either the name (in quotes) or internal ID of a parameter list (This argument is optional.)
Characteristics of OPEN_FORM Is a restricted procedure Causes opened form to be modeless Can start a new database session Using Data Mode to Share PL/SQL Variable Data The data mode parameter can be used to share PL/SQL variable data between forms. Create a package that contains the PL/SQL variables to be shared, and place the package in a library. Attach the library to all the forms that are to share the data. In the OPEN_FORM command, set the data_mode parameter to SHARE_LIBRARY_CODE. Any changes made by one form are visible to the other forms. This method of sharing data between forms is preferable to global variables because the PL/SQL variables benefit from PL/SQLs strong typing and because PL/ SQL variables are stored and accessed more efficiently than global variables.
Closing Forms
Characteristics of CLOSE_FORM: Restricted Not valid in Enter-Query mode CLOSE_FORM or EXIT_FORM Cannot close a form that called another form
Instructor Note Demonstration: Use FormFirst.fmb, FormNext.fmb, and FormPost.fmb. Run FormFirst on the Web and use the button toolbar to demonstrate use of OPEN_FORM, CALL_FORM and NEW_FORM, post mode, parameter passing and shared libraries. Explanation for next page pair (Navigating between Forms): Use of NEXT_FORM stops the execution of subsequent statements in the trigger or program unit. The When-New-Form-Instance trigger only fires on navigation into a form when the form is initially started. The When-Window-Activated trigger should be used for synchronizing forms in a multiple-form application. Use dept.fmb to open or call emp.fmb in order to illustrate when the triggers fire.
Closing Forms
Syntax
CLOSE_FORM(form_name); CLOSE_FORM(form_id); Parameter form_name form_id Description The module name of the form (not the .fmx filename) The internal form module ID of the form (of type Form Module)
Characteristics of the CLOSE_FORM Procedure CLOSE_FORM is a restricted procedure that is not valid in Enter Query mode. When the specified form is the current form, CLOSE_FORM is equivalent to EXIT_FORM. You cannot close a form that has called another form with CALL_FORM. Web Design Tip The Oracle Forms Developer application will continue if you attempt to exit your Web-deployed form application by closing the browser window, while other browser windows are still open. It will not terminate until the browser is also closed down. It is recommended that users are always able to close their applications either with the CLOSE_FORM or the EXIT_FORM commands. Applications that are not terminated will continue until timed out by the Oracle Forms Server.
Each open form has a current item. There is no validation when navigating between forms. No triggers fire when navigating between forms, except the When-WindowActivated/Deactivated and When-Form-Navigate triggers. Click the noncurrent item in the other form.
PREVIOUS_FORM
GO_FORM
Navigation and Validation Aspects of Inter-form Navigation In a multiple-form application, each open form has one item that is the current item for that form. When you are navigating between open forms, no validation occurs in the starting form. When you return to the starting form and attempt to navigate within that form, normal validation is enforced. When you are navigating between (current items of) open forms, no triggers fire. The only exceptions are the When-Window-Activated, When-Window-Deactivated, and When-Form-Navigate triggers. Even the navigational triggers do not fire when you are navigating between open forms. If you click a noncurrent item of an open form, triggers that would usually fire, when you are navigating from the current item to the target item, fire. In this case, navigational triggers also fire and validation occurs as required.
Session
CALL_FORM(form_name, display, CALL_FORM(form_name, display, switch_menu, query_mode, switch_menu, query_mode, data_mode, paramlist); data_mode, paramlist);
Characteristics of CALL_FORM
Unrestricted Valid in Enter Query mode Savepoint issued Modal with respect to calling form Does not cause navigation and validation Forms called from query-only form are always query-only Exiting a called form
Instructor Note Demonstration: Use FormFirst.fmb to call FormNext.fmb. Illustrate use of HIDE, NO_HIDE, and QUERY_ONLY arguments .
Characteristics of CALL_FORM Is valid in Enter Query mode Causes Forms to issue a savepoint Causes called form to be modal Does not cause navigation or validation in the initial form Can call a form in Query Only mode Propagates query-only parameter through all subsequent called forms Returns control to the calling form and resumes processing of the PL/SQL code at the statement immediately following the calling statement (This occurs when Forms exits the called form.)
Instructor Note Demonstration: Use FormFirst.fmb to call FormPost.fmb in post only mode.
Do not confuse call savepoints, which are set when a form is called or started, with post savepoints, which are set at the start of a post.
IF <form called> THEN IF <form called> THEN POST; POST; ELSE ELSE COMMIT_FORM; COMMIT_FORM; END IF; END IF;
Adjusting Default Transaction Processing for Called Forms The characteristics of Post-Only mode and the rollback behavior of called forms require that you adjust default transaction processing as follows: Redefine [Commit] so that processing performs a post when the form is called. Redefine [Exit] so that processing does not perform a rollback when the form is called. You may want to adjust the labels of possible buttons and menu items that correspond to [Commit] and [Exit]. Examples Key-Commit trigger at form level:
BEGIN IF GET_APPLICATION_PROPERTY(calling_form) is not null THEN POST; ELSE COMMIT_FORM; END IF; END;
NEW_FORM(form_name, rollback_mode, NEW_FORM(form_name, rollback_mode, query_mode, data_mode, query_mode, data_mode, paramlist); paramlist);
Description The file holding the executable form module Either TO_SAVEPOINT (the default), NO_ROLLBACK, or FULL_ROLLBACK Either NO_QUERY_ONLY (the default) or QUERY_ONLY (This defines whether the called form should run in Query Only mode.) Either NO_SHARE_LIBRARY_DATA (the default) or SHARE_LIBRARY_DATA Either the name (in quotes) or internal ID of a parameter list (This argument is optional.)
Web Design Tip With small Web-deployed form modules, you can reduce the time to download your applications from the server. You can easily link Form modules together by using the OPEN_FORM and NEW_FORM built-ins. You can therefore provide users with all the functionality that they require, when they need it.
Form D
Form B OPEN_FORM S.P. CALL_FORM Form E Form A+B+E = Call form stack
Form F
Technical Note You can obtain information about the call form stack by using the GET_APPLICATION_PROPERTY built-in with the CALLING_FORM parameter. Instructor Note The slide illustrates the restrictions on using OPEN_FORM and CALL_FORM. In this scenario, Form A calls Form B, Form B then opens Form C, Form C then opens Form D; and Form B then calls Form E. The call is not allowed to navigate to Forms A and B. The current call form stack consists of Forms A, B, and E. A form cannot be called from Form C and D. Changes in any form are rolled back to the savepoint (S.P.) that was set when Form E was called.
When to use OPEN_FORM When to open a form in a new session When to use CALL_FORM When to use NEW_FORM
Instructor Note With use of WEB.SHOW_DOCUMENT you are able to navigate between opened forms by using the browser BACK and FORWARD buttons. This command is covered in a later lesson.
P1 P2 P3
Parameter list
Instructor Note Demonstration: Use FormFirst.fmb to demonstrate communication with Form Parameters and also with Shared Libraries (Passvalues.pll). Switch toolbars in FormFirst.fmb to open FormNext with parameters or shared library values.
Example Pass a value for the CUS_ID form parameter to the ORDITEM form by way of the Runtime command line. Note that MODULE and USERID are predefined command line parameters.
ifrun60.exe module=orditem userid=scott/tiger cus_id=202
Referencing Form Parameters You can reference form parameters in a way similar to how you would access Forms variables. To reference the parameter contents, use bind-variable syntax: :PARAMETER.parameter_name, where the reserved word PARAMETER is the fixed part. To reference the parameter name, put the fully qualified name between single quotation marks: PARAMETER.parameter_name Example Assign the value of the CUS_ID form parameter to the CUSTOMER_ID item in the ORDER block.
:order.customer_id := :PARAMETER.cus_id;
Parameter Lists
Parameter list
CUS_ID TEXT_PARAMETER 204
) ) )
Technical Note You must define the parameters whose values are being passed to a form in that form at design time.
Parameter Lists
One way to supply form parameter values is to specify a parameter list in the call to the built-in that invokes the form. What Is a Parameter List? A parameter list is a named programmatic construct that lists parameter names (called keys), their types, and their values. You can specify parameter lists in the calls to the following built-ins: CALL_FORM OPEN_FORM NEW_FORM RUN_PRODUCT Two Parameter Types
Type Text Parameter Description A simple parameter with a scalar, noncomposite CHAR value. You must use this type of parameter, unless you want to pass a record group to another Oracle product. A parameter whose value must always be the name of a record group defined in the current form. Data parameters are used to pass data to products invoked with the RUN_PRODUCT built-in. You cannot pass data parameters to forms.
Data Parameter
Default Parameter List Each form includes a built-in parameter list named DEFAULT. The DEFAULT parameter list contains all of the form parameters that were defined in the form at design time. Like any other parameter list, the DEFAULT parameter list can be specified in the call to the built-ins that can invoke a form.
Name
Technical Note You cannot create a parameter list named DEFAULT or one that already exists. Use GET_PARAMETER_LIST and ID_NULL to check whether a parameter list already exists.
ADD_PARAMETER
1. 2. 3. 4.
If a parameter list exists, destroy it. Create a parameter list. Add a text parameter to a list with the value of an item. Open a form with this parameter list.
Form A Run time parameters P1 P2 P3 OPEN_FORM(*) Form B Design-time parameters P1 P2 P3
Characteristics of form parameters: Can be used only as input parameters Have data type CHAR, NUMBER, or DATE CHAR parameter can be up to 64 K long Can be design-time objects
Characteristics of global variables: Are programmatic constructs Have type CHAR(255) Are visible to all forms in the current Runform session
Technical Note Global variables are used more often than parameters for passing data between forms.
Note: You must define the CUS_ID parameter in the ORDITEM form at design time, because each run-time parameter must have a corresponding design-time parameter in the target form. Form Parameters and Global Variables Form parameters can be used only as input parameters; the invoked form cannot return modified form-parameter values to the invoking form. Therefore, global variables are the preferred method for communicating between forms. Advantages of form parameters include: - They have a data type of CHAR, NUMBER, or DATE. - The length of a CHAR parameter can be up to 64 K. - They can be design-time objects. - Global variables are always programmatic constructs of type CHAR(255). They are visible to all the forms in the current Runform session.
Summary
Open, call, and close forms: OPEN_FORM, CALL_FORM, and CLOSE_FORM Multiple database sessions
Navigate between forms: NEXT_FORM, PREVIOUS_FORM, and GO_FORM Identify restrictions on the call form stack
Summary
Manage Transaction processing in: Opened forms: Within same or different sessions Called forms: Post-Only mode; a rollback to savepoint
Create form parameters and parameter lists Methods for parameter passing Referencing form parameters Text parameters and Data parameters Built-ins for parameter lists
Summary ......................................................................................................................................................
Summary
The Three Built-ins for Invoking Forms OPEN_FORM CALL_FORM NEW_FORM Opening, Calling, and Closing Forms OPEN_FORM CALL_FORM CLOSE_FORM Built-ins for Navigation Between Forms NEXT_FORM PREVIOUS_FORM GO_FORM Controlling Open Forms and Called Forms Together Restrictions on the call form stack Transaction Processing for Open Forms Within the same session or different sessions Transaction Processing for Called Forms Characteristics of Post-Only mode Rollback behavior of called forms: default rollback to savepoint Using Form Parameters Passing parameter values to a form by way of Runform command line or parameter list Referencing form parameters using PARAMETER.parameter_name Using Parameter Lists The two parameter types: text parameters and data parameters The default parameter list named DEFAULT Built-ins for creating and manipulating parameter lists
Practice 9 Overview
Implementing a multiple form application by calling SALESREP from CUSTOMERS Performing an automatic query on the SALESREP form, based on the Sales Rep ID value in the CUSTOMER form Ensuring that posted changes in SALESREP are not rolled back Passing a parameter list from CUSTOMERS to SALESREP
Practice 9
1 Create a multiple-form application by linking the CUSTOMERS and the
SALESREP forms. The SALESREP form provides a look up facility for :S_CUSTOMER.SALES_REP_ID. It replaces the SALES_REP_LOV list of values. Values are selected by mouse double click. a Open SALESREP form and save as SALESREPXX where XX is your student course number. b In your CUSTOMERS form, modify the code in the SALES_LOV_BUTTON When-Button-Pressed trigger to call the SALESREP form. c Ensure that the user can see, but not navigate to, your CUSTOMERS form, while the SALESREP form is open. d Update :S_CUSTOMER.SALES_REP_ID with the value selected by the user in the SALESREP form. The selected Sales Rep ID is returned in a GLOBAL variable called salesrepid. This variable contains either a valid value or the text NOT SELECTED. e Save and compile your form. Deploy your form to the Web to test.
2 Modify your multiple-form application to enable the SALESREP form
to be called in post mode only. a Hide the CUSTOMERS form when the SALESREP form is displayed. b In the SALESREP form, ensure that whenever the form has been opened by CALL_FORM, that a [Commit Form] performs a POST. c Ensure that updates in SALESREP are not cleared when the user exits the form. d Save and compile your form. Deploy your form to the Web to test.
3 The SALESREP form displays a list of all employees; modify your
application to ensure that only Sales Representatives are displayed when the form is called from CUSTOMERS. a Create a parameter called EVERYONE in the SALESREP form. Specify a default value of Y.
Practice 9 ......................................................................................................................................................
Ensure that the SALESREP form will perform an unrestricted query whenever the parameter value = Y. If the parameter value = S, a restricted query should be performed, selecting only Sales Representatives. c In the CUSTOMERS form, pass the parameter value S to the SALESREP form. Create a parameter list called EMPS. Add the EVERYONE parameter to the parameter list. The type of this parameter is TEXT_PARAMETER, and it is initialized with the value S. Pass the parameter list to the SALESREP form by using the CALL_FORM built-in. You can import the code from the pr9_1.txt file. d Save and compile your forms. Deploy your form to the Web to test.
b
10
................................
Objectives
Describe the record group object Use record groups Define record groups at design time Control record groups by using built-in functions Define query record groups programmatically Define nonquery record groups programmatically
Objectives
Manipulate record group rows Define lists of values (LOVs) programmatically Manipulate list items programmatically Implement dynamic list items Add values to combo boxes
Instructor Note
Topic Lecture Practice Total Timing 50 minutes 30 minutes 80 minutes
Introduction ......................................................................................................................................................
Introduction
Overview Record groups are useful constructs for storing structured data, and they can be manipulated at run time. This lesson covers how to create, modify, and delete record groups at design time and programmatically at run time. It also covers how you apply record groups in useful ways, such as for dynamic list items. Objectives After completing this lesson, you should be able to do the following: Describe the record group object Use record groups Define record groups at design time Control record groups by using built-in functions Define query record groups programmatically Define nonquery record groups programmatically Manipulate record group rows Define lists of values (LOVs) programmatically Manipulate list items programmatically Implement dynamic list items Add values to combo boxes
Record Groups
Three record group types: SOURCE TIME Design Time Run Time Based on a SELECT Statement QUERY QUERY Not Based on a SELECT Statement STATIC NON QUERY
Record Groups
Forms implicitly creates query record groups. Use SET_LOV_PROPERTY to replace default record group.
... ... IF Get_LOV_Property(lov_id,GROUP_NAME) = 'GROUP1' IF Get_LOV_Property(lov_id,GROUP_NAME) = 'GROUP1' THEN THEN Set_LOV_Property(lov_id,GROUP_NAME,'GROUP2'); Set_LOV_Property(lov_id,GROUP_NAME,'GROUP2'); END IF; END IF; ... ...
Record Groups
What Is a Record Group? A record group is an internal Forms data structure that is similar to a database table. It can have columns of type CHAR, NUMBER, or DATE, and its data is stored in rows. Record groups exist in local Forms memory, rather than in the database. Three Record Group Types
Type Query Record Group Description A record group with an associated SELECT statement. The columns in the record group derive their properties from the columns in this SELECT statement. The rows in the record group are the rows retrieved by this SELECT statement. This type of record group can be created at design time and at run time. A record group without an associated query. The columns and rows of the record group are defined programmatically at run time and can also be modified at run time. A record group without an associated query. The columns and rows of the record group are defined at design time and cannot be modified programmatically at run-time.
Note: When you create a record group, you cannot specify its type explicitly. The type is implied by when and how you create the record group. Record Groups and LOVs When you create a list of values (LOV) based on a query, Form Builder implicitly creates a query record group. In this case, the columns and rows of the record group are determined by the LOV SQL query statement. At run time, you can call the SET_LOV_PROPERTY built-in function to replace the default record group of an LOV with another one. Use the GROUP_NAME property.
Constructing dynamic SELECT statements Storing form-configuration information Communicating within a form Passing data to other forms Passing data to other Oracle products Populating or storing list items
Instructor Note Demonstration: Use rec_grp.fmb to demonstrate how you create query record groups (CUSTOMER_ID) and static record groups (STATIC_GROUP).
CREATE_GROUP
CREATE_GROUP_FROM_QUERY
Name
Name, Query
Record group ID
Record group ID
ID
Name
DELETE_GROUP
ADD_GROUP_ROW Row No ID 1 201 2 3 203 4 204 DELETE_GROUP_ROW Name Unisports Delhi Sports Womansport Address
ADD_GROUP_COLUMN
Instructor Note Point out that CREATE_GROUP_FROM_QUERY does not populate the record group. ADD_GROUP_ROW adds an empty row. Row No is an internal number.
DELETE_GROUP
ADD_GROUP_ROW DELETE_GROUP_ROW
SELECT ID, name FROM s_customer ID 201 202 203 204 Name Unisports SImms Athletics Delhi Sports Womansport
POPULATE_GROUP (_WITH_QUERY)
GET_GROUP_NUMBER_CELL
Technical Note POPULATE_GROUP built-in function returns 0 when population succeeds and 1 if population does not succeed.
POPULATE_GROUP_WITH_QUERY
Note: You can convert a nonquery record group into a query record group by using the POPULATE_GROUP_WITH_QUERY built-in function to populate the nonquery record group. Getting Record Group Cell Values
Built-in Function GET_GROUP_CHAR_CELL, GET_GROUP_DATE_CELL, GET_GROUP_NUMBER_CELL Description Returns the value for the record group cell identified by the given record group column and row number (The record group column must be of data type VARCHAR2 or LONG, DATE, or NUMBER, respectively.)
GET_GROUP_SELECTION_COUNT
Selection No 1 2
Row No 1 2 3 4
SET_GROUP_SELECTION GET_GROUP_SELECTION
Copyright Oracle Corporation, 2000. All rights reserved.
Instructor Note Explain the built-ins and describe how with SET_GROUP_SELECTION, if you select rows 2 and 4, the associated selection numbers are 1 and 2. Explain that the record group type (query, nonquery, static) and time of creation (design time or run time) determine which built-in functions are valid for a particular record group.
FIND_COLUMN
Instructor Note Demonstration: Use rec_grp.fmb to demonstrate the code for creating a query record group. Use the procedure DEFINE_QUERY_RECORD_GROUP.
You can replace the associated query of a query record group by calling the POPULATE_GROUP_WITH_QUERY built-in function.
v_errcode := POPULATE_GROUP_WITH_QUERY(v_rg_id, SELECT id, name FROM s_customer where region_id = 1 ORDER BY id);
Instructor Note Demonstration: Use rec_grp.fmb to demonstrate the code for creating a nonquery record group. Use the procedure DEFINE_NON_QUERY_RECORD_GROUP.
You can convert the nonquery record group into a query record group by calling the POPULATE_GROUP_WITH_QUERY built-in function.
Get number of group rows Cell value= given value Yes Return row number Return NULL No
Instructor Note Demonstration: Use rec_grp.fmb to demonstrate the code for manipulating record group rows. Use the GET_VALUE_GRPROW function to show the code that you use to search for a specific value in a record group. Explain that this technique can be used with a combo box to determine whether or not the value already exists in the record group.
Instructor Note Demonstration: Use rec_grp.fmb to demonstrate the code for manipulating selected record group rows. Use the SELECT_EVEN_ROWS procedure to show the code for searching for a specific row in a record group. Use the GET_VALUE_GRPSEL function to show the code for looping through the row in a record group. Explain that the even number can be identified by using the MOD function.
The function below illustrates how you can loop through all selected rows of a record group.
FUNCTION get_value_grpsel /* Returns selection number of selected group row that contains the specified value in the given group column. Returns NULL if the value is not found. */ (p_rg_id in RECORDGROUP ,p_gc_id in GROUPCOLUMN ,p_value in VARCHAR2) RETURN NUMBER IS v_grpsel_count NUMBER; v_grprow_no NUMBER; BEGIN --Only loop through the selected group rows. v_grpsel_count := GET_GROUP_SELECTION_COUNT(p_rg_id); FOR v_grpsel_no IN 1 .. v_grpsel_count LOOP --Get row number of selected row. v_grprow_no := GET_GROUP_SELECTION(p_rg_id,v_grpsel_no); IF GET_GROUP_CHAR_CELL(p_gc_id,v_grprow_no) = p_value THEN RETURN(v_grpsel_no); END IF; END LOOP; RETURN(null); END;
Record group visible to all forms in an application Scope parameter FORM_SCOPE (default) GLOBAL_SCOPE
...CREATE_GROUP(group_name, scope); ...CREATE_GROUP(group_name, scope); ...CREATE_GROUP_FROM_QUERY(group_name, ...CREATE_GROUP_FROM_QUERY(group_name, query, scope); query, scope);
Technical Note If a global record group is created from (or populated with) a query while executing a Form A, and the query string contains bind variable references that are local to A (:block.item or :PARAMETER.param), then when Form A terminates execution, the global query record group is converted to a global nonquery record group. The record group retains its data, but a subsequent POPULATE_GROUP is considered an error. Instructor Note Demonstration: Use Orders2.fmb to demonstrate the use of a global record group. Click the Product_Lov button to display a list of values form. Using [Ctrl] + click, select the products that you want. Then click the OK button. The products selected are returned by way of a global record group to the ORDERS form. You can show the When-Mouse-Click trigger of the lov_product form.
DELETE_LIST_ELEMENT GET_LIST_ELEMENT_COUNT
RETRIEVE_LIST
Using a Record Group with a List Item You can transfer information between a list item and a record group by using the POPULATE_LIST and RETRIEVE_LIST built-in functions. The record group that is used as the second parameter for these functions must satisfy these requirements: The record group must contain exactly two group columns of type CHAR. The first group column must store the list element label. The second group column must store the list element value.
Create group rrom query Populate group Yes Populate list Display first list label
Success?
No
Instructor Note Demonstration: Use rec_grp.fmb to demonstrate the code of the POPULATE_LIST_WITH_QUERY procedure. Explain that the When-Create-Record trigger is used because it is too late for the When-List-Changed trigger to here. Another option is to use the When-Mouse-Down trigger.
Note: In this example, the customer name is the (visible) list label and the customer ID is the (actual) list value.
Get number of list elements Element value= Item value? Yes Return Add list element with item value No
Instructor Note Demonstration: Use rec_grp.fmb to demonstrate the code of the ADD_COMBO_BOX_ELEMENT procedure.
Summary
In this lesson, you should have learned how to: Define design-time query and static record groups
Define run time query and non-query record groups Use Built-in functions for populating record groups Define Global record groups
Summary
Use record groups for: Constructing dynamic SELECT statements Storing or passing data Populating or storing list items
Summary ......................................................................................................................................................
Summary
A record group is an internal Forms data structure that is similar to a database table. Three Record Group Types Query record group Non query record group Static record group Defining Record Groups at Design Time Creating query and static record groups Modifying SELECT statements and column definitions of record groups Built-ins for Controlling Record Groups Creating and deleting record groups Modifying the structure of record groups Populating record groups Getting record group cell values Processing record group rows Finding record group objects Defining a Global Record Group Created at run time only Visible to all forms in an application Scope parameter Uses for Record Groups Constructing dynamic SELECT statements Storing form configuration information Communicating within a form Passing data to other Oracle products Populating or storing list items Manipulating List Items Programmatically Built-in for list items
Practice 10 Overview
Basing a dynamically populated list item on a design-time query record group Basing a dynamically populated list item on a run-time query record group
Practice 10
1 Create a dynamic list item populated from a design-time query record
group. The record group will hold region ID and the name of the departments in the S_DEPT table. a Open the Employees form. Save as EmpXX where XX is your student course number. In the Object Navigator, create a record group named DEPT_ID based on the query below:
SELECT name || in region || TO_CHAR(region_id) Name, TO_CHAR(id) Id FROM s_dept ORDER BY 1 b
Convert the text item DEPT_ID into a list item, with a Poplist style. Resize the list item in the Layout Editor. c Create one element in the list item. Specify a label of Dummy and a value of 0. d Create a procedure called POPULATE_DEPT_LIST. This procedure will accept the list item name as an argument and populate the list item dynamically at run time, using the design-time query record group. You can import the code from the pr10_1.txt file. e Call the procedure each time a new record is created. f Save and compile your form module to test.
If you have time 2 Replace the design-time query record group in the Employee form with a run-time query based record group. a Delete the DEPT_ID record group and remove the code from the When-Create-Record trigger.
Practice 10 ......................................................................................................................................................
Create a procedure called CREATE_DEPT_LIST which will dynamically create a record group called QDEPT, if it does not already exist. The procedure will also populate the record group by using the query:
SELECT name ||TO_CHAR(region_id) Name, TO_CHAR(id) Id FROM s_dept ORDER BY 1
The procedure will also populate the list item S_EMP.DEPT_ID. d You can import the procedure code from pr10_2.txt file. e Call the procedure from the When-Create-Record trigger. f Save and compile your form module to test.
11
................................
Objectives
Instructor Note
Topic Lecture Practice Total Timing 20 minutes 35 minutes 55 minutes
Introduction ......................................................................................................................................................
Introduction
Overview In this lesson, you will learn about the reusable components that are available with Oracle Forms Developer. You will learn how these components can fit into any application. Objectives After completing this lesson, you should be able to do the following: List the reusable components Include the calendar object in an application
Reusable Components
Picklist
Calendar
Instructor Note Students may copy and use the icons, images, ActiveX controls, menus, and all other files provided in the demonstrations into their own applications. Oracle Corporation retains all copyrights on these demonstrations, components, icons, ActiveX controls, and images. There is no license or fee required for any such reuse. However, Oracle Corporation does not provide any support for these components. These components are provided as is. Some of the demonstrations and reusable components require PL/SQL features that are supported only in Oracle7 release 7.3 or later.
Reusable Components
Oracle Forms Developer contains a complete set of demonstrations that illustrate the power and productivity of the product. These demonstrations contain many tips and techniques that you can copy and use in your own applications. Reusable Component Definition A reusable component is a generic object (object group, block, PL/SQL library, and so on) that you can reuse in all your applications. You can create your own reusable components (code and object) by using the generic programming characteristics. Oracle Forms Developer also includes a number of reusable components that enable you to easily and rapidly build applications that provide power and performance while conforming to GUI standards. These components are customizable. Web Design Tip JavaBeans and Enterprise JavaBeans are reusable components that may be used with Web-deployed Oracle Forms Developer applications. These allow you to create a customized look and feel for the user interface, and to add additional functionality. The deployment of JavaBeans is covered in a later lesson.
ActiveX controls Java Beans Sample Icons Standard Menus PL/SQL Drag & Drop Library PL/SQL Utilities Library PL/SQL Conversion Library PL/SQL Window System Interface Library
Instructor Note Demonstration: Use Orders.fmb to demonstrate the implementation of the calendar class and the picklist class. Navigate to the DATE_ORDERED item and press [F9] to display the calendar. Click the PRODUCT_LOV button to display the picklist form.
Standard menus PL/SQL Drag and drop library PL/SQL Utilities library PL/SQL Conversion library PL/SQL Window system interface library
Standard Object Library Calendar class Picklist class Wizard class Navigator class Help class Oracle Applications Object Library
Description The object library, stndrd20.olb, contains standard classes and visual attribute groups to help you build your applications to a standard look and feel. Some objects in the library are set as SmartClasses so that they can be readily applied to the objects created in your forms. This stndrd20.olb library component enables you to add a calendar or date list of values to your application This stndrd20.olb library component enables you to easily add a picklist or chooser-style interface to an application, and to provide functionality that mimics the picklists of wizards and other dialogs. This stndrd20.olb library component enables you to easily add a wizard-style interface to an application, and to provide functionality that mimics the wizards of the Oracle Forms Developer builders and other Windows products. This stndrd20.olb library component enables you to build an online Help facility with a Windows look and feel. Help text is stored on the database. The object library, appsstds.olb, contains property classes and visual attribute groups that enable you to build modules that have the same look and feel as Oracle Applications. They have a Windows look and feel, but they have also been designed for maximum portability.
Wizard class
Help class
Creating a Calendar
To create a calendar: 1. Copy or make the Calendar Object Group a subclass. 2. Attach the PL/SQL library CALENDAR.PLL. 3. Create a Key-Listval trigger. 4. Call Date_LOV.Get_Date.
Syntax
Example
Argument display_date return_item v_x_pos v_y_pos v_title v_ok v_cancel v_highlight v_autoconfirm v_autoskip
Description The date to display when the Date List of Values window first appears The name of the block and item to which to return the chosen date Specifies the X coordinate of the Date List of Values window Specifies the Y coordinate of the Date List of Values window Title to display in the Date List of Values window Label for the OK button Label for the Cancel button Specifies that weekend days appear in a different color Specifies that the date immediately be returned when the end user clicks a day Specifies that the input focus moves to the next item in sequence
Summary
Indentify reusable components in Oracle Forms Developer Create a Calendar class: Copy forms objects from calendar object library Copy PL/SQL code from calendar PLSQL library
Summary ......................................................................................................................................................
Summary
Reusable Components The purpose of a reusable component Reusable components list The Calendar Class Create a calendar Calendar Object Group content Built-in for manipulating the calendar
Practice 11 Overview
Creating a picklist class to display and select the products available Attaching a calendar class to ORDERS date items: date_ordered date_shipped
Practice 11
1 Create a picklist by using the picklist class. This picklist enables the end
user to select order items from a product list, and to place selections in a second list. a Create a new form module, called PICKXX where XX is your student course number. Open the Form_Builder_II.olb object library. This library contains form objects and code for the picklist. Copy the PICKLIST_BASIC object group to your form module. Copy the PICKLIST object group into your new form module. b Ensure the CONTROL block is the last defined data block in the object navigator. c Attach the picklist.pll library. This contains the functions and procedures required for creating the picklist. d Define a When-New-Form-Instance trigger which will create and populate the picklist. You can import the code from the pr11_1.txt file. Create the picklist with the picklist.Create_Picklist procedure. Call function pick_list.Populate_Picklist_With_Query to populate the List_in object. You must define a query that returns the ID, name and suggested prices from the S_PRODUCT table. Call pick_list.Set_Picklist_Selection procedure to select the first element in the list. Display both lists by using the pick_list.Display_Picklist procedure. Exclude from the query any products already in the current S_ITEM block. You should use the global variable :GLOBAL.where_cls. e Save and compile your form. Deploy your form to the Web. f In your ORDERS form, modify the When-Button-Pressed trigger for the CONTROL.PRODUCT_LOV_BUTTON so that it calls your new form module. g Save and compile your form. Deploy your form to the Web to test.
If you have time 2 In the ORDERS form, add a calendar on the S_ORD.DATE_ORDERED item and S_ORD.DATE_SHIPPED item. a From the calendar page of the Form_Builder_II.olb object library, copy the calendar object group.
Practice 11 ......................................................................................................................................................
Attach the PL/SQL library calendar.pll, which contains the Date_LOV package, to your module. c Create a Key-Listval trigger on the date ordered item. Add code to display the calendar using the Date_LOV package. You can import the code from the pr11_2.txt file. d Create a Key-Listval trigger on the date shipped item. Add code to display the calendar using the Date_LOV package.You can import the code from the pr11_3.txt file. e Save and compile your form module. Deploy your form to the Web to test.
b
12
................................
Objectives
Customize the user interface Incorporate JavaBeans in Web-deployed forms by: Inserting Pluggable Java Components Creating Bean Areas
Instructor Note Emphasize that use of Java in Oracle Forms Developer does not require Java programming skills. Students can build Web-deployed forms applications by reusing Java class files, supplied either by Oracle or a third party. Instructor Note
Topic Lecture Practice Total Timing 40 minutes 25 minutes 65 minutes
Introduction ......................................................................................................................................................
Introduction
Overview In this lesson you will learn how to enhance Web-deployed forms by using JavaBeans to customize the user interface. You will also learn about Oracle8i features that may be used within Web-deployed Oracle forms. Objectives After completing this lesson, you should be able to do the following: Customize the user interface Incorporate JavaBeans in Web-deployed forms by - Inserting Pluggable Java Components - Creating Bean Areas Exploit Oracle8i features with Web-deployed forms
Java and Oracle Forms Developer Java class files Java Runtime
Environment
Platform independent programs A Java Virtual Machine executes class files in web browser Downloads class files to create and maintain the Forms user interface
Forms Applet
Instructor Note Advise students requesting further information on the deployment of Web forms to attend the Oracle Forms Server: Deploy Internet Applications course.
Oracle Look and Feel is defined in the Forms Applet base HTML file
<HTML><BODY> <EMBED type="application/x-jinit-applet" java_CODE="oracle.forms.engine.Main" java_CODEBASE="/web_frms/" java_ARCHIVE="f60all.jar" WIDTH=750 HEIGHT=400 serverPort="5555" serverArgs="module=emp userid=scott/tiger@mydatabase" serverApp="/web_html/summit" pluginspage="http://machine/jinit_download.htm" splashScreen="/web_img/summitlo.gif" lookAndfeel="Oracle" colorScheme="teal"> </EMBED> </BODY></HTML>
lookAndFeel colorScheme
Determines the application's look and feel. Values: Oracle or Generic (Windows 95 look-and-feel). Default value is Generic. Determines the application's color scheme. Values: Teal, Titanium, Red, Khaki, Blue, Olive, or Purple. Ignored when lookAndFeel is set to Generic.
Technical Note To enable the Web Previewer, you must have installed the Forms Server Runtime Engine in your test environment. Instructor Note The JVM that is used by the Forms Applet may be: Browser JVM Oracle JInitiator Applet Viewer Only MS Internet Explorer (IE) version 5 is certified to run the Forms Applet natively. This is a Netscape plug-in or a MS Internet Explorer ActiveX component that allows the Forms Applet to be run in a browser. This Java tool allows you to run the form Applet without using a browser.
Macintosh Font
Courier Geneva Geneva Helvetica Symbol Times Roman
At run time, Oracle Form Developer fonts are converted to their Java equivalent via reference to an alias file, Registry.dat. If your selected Oracle Form Builder font does not map to a supported Java font, it will be replaced with the default Java font. You can specify the default Java font by editing the Java registry file. The Registry.dat file is located in: ORACLE_HOME/forms60/java/oracle/forms/registry/
Y
Smoking ?
Radio Buttons
Select a valid Form Item Specify the name and path of your PJC in the Implementation Class property:
Pluggable Java Components Oracle provides Java class files for building components in Web-deployed forms. The default value is the name of the standard PJC supplied with Oracle Forms Developer. To use your own PJC, you must supply the fully qualified name of the PJC Java class file:
Implementation Class property Default value Fully qualified name of PJC Example Description Oracle supplied PJC; value not displayed in property palette Custom PJC specified by application developer. oracle.forms.demos.SecureText
Example: Specifying the Securetext PJC This PJC will display salary data as asterisk characters. When the user clicks on the field, the PJC will reveal the salary values: Open the Property Palette for :EMP.SAL and select the Implementation Class property. Specify the full name of the PJC: oracle.forms.pjc.demo.SecureText Form Builder will search for the file SecureText.class in the demos directory, in the path FORMS60_JAVADIR/oracle/forms/ Compile the form module. Location of PJC Class Files You should specify the FORMS60_JAVADIR environment variable to enable Oracle Forms Developer to locate your JavaBeans. The default path is: ORACLE_HOME/forms60/java. It is recommended that you place your custom JavaBean class files within a sub-directory in this path. Instructor Note. Use JAVAMENU.fmb to demonstrate the implementation of JavaBeans as PJC: CursorPJC changes the cursor appearance, giving functionality similar to Mouse Movement triggers. SecureText is a PJC that conceals data values with asterisks until the user clicks on the item. Rollover Button is a JavaBean which displays different images as you move the mouse over the button.
Bean Areas
A Bean Area is a Forms item that enables you to incorporate JavaBeans in your Web-deployed forms. With Bean Areas you can: Add new control Hello Forms! items and new Someone hit the OK functionality
Execute Clientside Java code Communicate between Forms Server and Client with PL/SQL
button. heres the Date Changed event and a parameter list with the selected date
Instructor Note Use JAVAMENU.fmb to demonstrate the implementation of JavaBeans in Bean Areas. HyperLink is a JavaBean that allows the user to specify a URL and browse the Internet. Ticker is a JavaBean that displays the digital time.
Hosting a JavaBean
1. Define a Bean Area 2. Specify the JavaBean 3. JavaBean is visible in Layout Editor
Hosting a JavaBean
You can host a JavaBean in your Oracle Forms Developer application by creating a Bean area control item. Creating a Bean Area You can create a Bean Area in three ways: Use the Bean Area Item tool in the Layout Editor Use the Create icon in the Object Navigator Convert an existing item Associating a JavaBean with Your Bean Area In order to associate your JavaBean with the Bean Area, you will need to name the JavaBean class file in the Bean Area Implementation class property. This property entry is mandatory. Oracle Forms Developer will locate your JavaBean class files by searching the Java directory, specified in the FORMS60_JAVADIR environment variable. Java is a case sensitive language, and you must ensure that the class file name is precisely specified. You must also supply a fully qualified name. For example, the location of MyEg.class file is: FORMS60_JAVADIR/oracle/forms/demos/MyEg.class You should therefore specify an entry in the Implementation class property: oracle.forms.demos.MyEg After you have specified the Implementation class property, the JavaBean will be visible in the Bean Area (in the Layout Editor).
A JavaBean communicates with a Web-deployed form by issuing an event. When-Custom-Item-Event trigger System variables: :SYSTEM.CUSTOM_ITEM_EVENT :SYSTEM.CUSTOM_ITEM_EVENT_PARAMETERS
Description Name of Custom event dispatched by Java Bean; this is case sensitive. Name of Parameter list containing associated event data
How Forms Receives JavaBean CustomEvents Whenever the JavaBean communicates with your form, the When-Custom-Item-Event trigger will fire. This trigger should be attached to the Bean Area hosting the JavaBean. By examining the form module system variables from this trigger, you can identify which JavaBean CustomEvent has occurred, and take appropriate action.
Example
SET_CUSTOM_PROPERTY('alarm_clock',1, 'wakeuptime', 1000);
In the following example the When-Custom-Item-Event trigger examines the system variables to identify the contents of a parameter list sent by the JavaBean. The JavaBean has sent date and time information to the form, which is then displayed to the user via an alert.
Declare EventName varchar2(20) := :system.custom_item_event; EventValues ParamList; Eventvalue Typenumber; TempString varchar2(4000); Begin If EventName = ALARMFIRED' then EventValues := get_parameter_list( :system.custom_event_parameters); get_parameter_attr(EventValues, 'ALARMTIME', EventvalueType, TempString); If Summit_Show_Alert(Alarm Call: '||TempString) = alert_button1 then set_custom_property(AlarmClock', 1,wakeuptime', 1000); end if; end if; End;
JavaBeans In Oracle Forms Developer are: Predefined Java class files Reusable Java class files Managed with a PL/SQL interface (triggers and built-ins) No Java programming is required
Instructor Note. Oracle JDeveloper has specific tools for creating JavaBeans. You should make any students requesting further information on the creation of JavaBeans aware of Oracle Java and JDeveloper courses.
Summary
Define Oracle LookandFeel and Java fonts Incorporate Java in Web-deployed forms by: Inserting Pluggable Java Components Creating Bean Areas
Use Oracle 8i features by exploiting Java stored procedures, EJB and BC4J
Summary ......................................................................................................................................................
Summary
Customize the User Interface Specifying Oracle look and feel Specifying default Java fonts Create JavaBean Areas Inserting Pluggable Java Components Creating Bean Areas Communicating with JavaBeans Exploit Oracle8i Features with Web-Deployed Forms Java stored procedures Enterprise JavaBeans Business Components for Java
Practice 12 Overview
Providing an alternative UI for text items by including PJC for Changing the mouse cursor style Displaying secure data as asterisks
Instructor Note The practices include use of WEB.SHOW_DOCUMENT. Outline its functionality and explain to students that it will be covered in a later lesson.
Practice 12
1 Provide an alternative user interface for your Web-deployed forms by
including Pluggable Java Components (PJCs). a Open the JAVAEMP.fmb form module. Save as JAVAXX.fmb, where XX is your student course code. b Change the :EMP.SAL item so that values are displayed as asterisks at run time. Use the PJC PasswordFieldPJC.class. This class file is held in the folder: FORMS60_JAVADIR /oracle/forms/demos c Change the :EMP.ENAME item so that the mouse cursor changes to hand style whenever the cursor is moved over the item. Use the PJC ModCursor.class. This class file is held in the folder: FORMS60_JAVADIR /oracle/forms/demos d Use the built-in SET_CUSTOM_PROPERTY in an appropriate trigger, to specify the cursor style: SET_CUSTOM_PROPERTY(Emp.Ename,1, DOCURSOR,HAND); e Save and compile your form. Deploy your form to the Web to test.
2 Create a JavaBean area in the Layout Editor to enable users to specify
hyperlinks of their choice. a Create a new data block called LINK in your JAVAEMP form. b Create a Bean Area called HYPERLINK1 in the new data block and specify the class file HyperLinkWrapper.class. c Create an appropriate trigger to identify the user-supplied URL from the JavaBean, and to download his or her Web page. You can import the code from the pr12_1.txt file. d Create two text items, one called URL to accept a URL and one called LABEL to accept a URL label. These will enable the user to select a different URL. Set the maximum length for the URL text item to 255. e Create a push button with an appropriate trigger that will accept values from the URL and LABEL text items, and pass them to the JavaBean. You can import the code from the pr12_2.txt file. f Save and compile your form. Deploy your form to the Web to test.