Oracle Forms Developer Build Internet Applications 1. Instructor Guide [Volume 1]


247 43 3MB

English Pages 534

Report DMCA / Copyright

DOWNLOAD PDF FILE

Recommend Papers

Oracle Forms Developer Build Internet Applications 1. Instructor Guide [Volume 1]

  • 0 0 0
  • Like this paper and download? You can publish your own PDF file online for free in a few minutes! Sign Up
File loading please wait...
Citation preview

Oracle Forms Developer: Build Internet Applications I Volume 1• Instructor Guide .......................................................................................

40033GC10 Production 1.0 March 2000 M011343

Author

Copyright  Oracle Corporation, 2000. All rights reserved.

Ellen Gravina

David Ball

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:

Soley Celik

Restricted Rights Legend

Kathy Cunningham

Use, duplication or disclosure by the Government is subject to restrictions for commercial computer software and shall be deemed to be Restricted Rights software under Federal law, as set forth in subparagraph (c) (1) (ii) of DFARS 252.227-7013, Rights in Technical Data and Computer Software (October 1988).

Technical Contributors and Reviewers

Ken Goetz Andrey Ivkin Kenji Makita Jayne Marlow Ian Purvis Bryan Roberts Rie Saitoh Raza Siddiqui Kajornsak Sungchareon Ted Witiuk Publisher

Nita Brozowski

This material or any portion of it may not be copied in any form or by any means without the express prior written permission of Oracle Corporation. Any other copying is a violation of copyright law and may result in civil and/or criminal penalties. If this documentation is delivered to a U.S. Government Agency not within the Department of Defense, then it is delivered with “Restricted Rights,” as defined in FAR 52.227-14, Rights in Data-General, including Alternate III (June 1987). The information in this document is subject to change without notice. If you find any problems in the documentation, please report them in writing to Education Products, Oracle Corporation, 500 Oracle Parkway, Box SB-6, Redwood Shores, CA 94065. Oracle Corporation does not warrant that this document is error-free. Oracle is a registered trademark and Oracle Forms Developer, Oracle Forms Server, Oracle Reports Developer, Oracle Reports Server, and PL/SQL are trademarks or registered trademarks of Oracle Corporation. All other products or company names are used for identification purposes only and may be trademarks of their respective owners.

Contents .....................................................................................................................................................

Contents Preface Profile xvii Related Publications xviii Typographic Conventions xix Introduction Overview I-3 Course Objectives I-5 Course Content I-7 Lesson 1: Introduction to Oracle Forms Developer and Oracle Forms Server Introduction 1-3 Internet Computing Solutions 1-5 What Is Oracle Forms Developer? 1-7 What Is Oracle Forms Server? 1-9 Forms Server Architecture 1-11 Oracle Forms Developer Key Features 1-13 Form Builder Components 1-15 Oracle Toolkit and Oracle Multimedia 1-19 Getting Started in the Oracle Forms Developer Interface 1-21 Navigating Around the Form Builder Main Menu 1-23 Customizing Your Oracle Forms Developer Session 1-25 Saving Tools Preferences 1-27 Oracle Developer Environment Variables 1-29 Environment Variables and Y2K Compliance 1-31 Invoking Online Help Facilities 1-33 Introducing the Course Application 1-35 Summary 1-39 Practice 1 Overview 1-41 Practice 1 1-42

..................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I iii

Contents .....................................................................................................................................................

Lesson 2: Running a Form Builder Application Introduction 2-3 Application Deployment 2-5 Web Deployment: What You See at Run Time 2-7 Client-Server Environment: What You See at Run Time Identifying the Data Elements 2-13 Navigating a Form Builder Application 2-15 Modes of Operation 2-19 Retrieving Data 2-23 Performing a Restricted Query 2-25 Using the Query/Where Dialog Box 2-27 Inserting, Updating, and Deleting Records 2-31 Making Inserts, Updates, and Deletes Permanent 2-33 Displaying Errors 2-35 Summary 2-37 Practice 2 Overview 2-39 Practice 2 2-40

2-9

Lesson 3: Working in the Form Builder Environment Introduction 3-3 What Is Form Builder? 3-5 Form Builder Executables 3-7 Form Builder Module Types 3-9 Form Builder Components 3-11 Summary 3-23 Lesson 4: Creating a Basic Form Module Introduction 4-3 Creating a New Form Module 4-5 Creating a New Data Block 4-11 Modifying the Layout 4-23 Template Forms 4-25 Saving, Compiling, and Running a Form Module Practice 4-1 Overview 4-35

4-27

..................................................................................................................................................... iv Oracle Forms Developer: Build Internet Applications I

Contents .....................................................................................................................................................

Creating Data Blocks with Relationships 4-37 Creating a Relation Manually 4-43 Modifying a Relation 4-45 Running a Master-Detail Form Module 4-49 Summary 4-51 Practice 4-2 Overview 4-53 Practice 4-1 4-54 Practice 4-2 4-55 Lesson 5: Working with Data Blocks and Frames Introduction 5-3 Managing Object Properties 5-5 Controlling the Behavior of Data Blocks 5-15 Controlling the Appearance of Data Blocks 5-21 Controlling Frame Properties 5-25 More About Object Properties 5-27 Creating Control Blocks 5-33 Deleting Data Blocks 5-35 Summary 5-37 Practice 5 Overview 5-39 Practice 5 5-40 Lesson 6: Working with Text Items Introduction 6-3 What Is a Text Item? 6-5 Creating a Text Item 6-7 Modifying the Appearance of a Text Item 6-9 Associating Text with an Item Prompt 6-15 Controlling the Data of a Text Item 6-17 Altering the Navigational Behavior of a Text Item 6-23 Enhancing the Relationship Between Text Item and Database 6-25 Adding Functionality to a Text Item 6-27 Including Helpful Messages 6-33

..................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I v

Contents .....................................................................................................................................................

Summary 6-35 Practice 6 Overview 6-37 Practice 6 6-38 Lesson 7: Creating LOVs and Editors Introduction 7-3 What Are LOVs and Editors? 7-5 Defining an LOV 7-9 Creating an LOV by Using the LOV Wizard Defining an Editor 7-21 Summary 7-25 Practice 7 Overview 7-27 Practice 7 7-28

7-11

Lesson 8: Creating Additional Input Items Introduction 8-3 What Are Input Items? 8-5 Creating a Check Box 8-7 Creating a List Item 8-15 Creating a Radio Group 8-23 Summary 8-31 Practice 8 Overview 8-33 Practice 8 8-34 Lesson 9: Creating Noninput Items Introduction 9-3 What Are Noninput Items? 9-5 Creating a Display Item 9-7 Creating an Image Item 9-11 Creating a Sound Item 9-19 Creating a Push Button 9-25 Creating a Calculated Item 9-31 Creating a Hierarchical Tree Item 9-39

..................................................................................................................................................... vi Oracle Forms Developer: Build Internet Applications I

Contents .....................................................................................................................................................

Summary 9-41 Practice 9 Overview 9-43 Practice 9 9-44 Lesson 10: Creating Windows and Content Canvases Introduction 10-3 Windows and Content Canvases 10-5 Displaying a Form Module in Multiple Windows 10-9 Displaying a Form Module on Multiple Layouts 10-15 Summary 10-19 Practice 10 Overview 10-21 Practice 10 10-22 Lesson 11: Working with Other Canvases Introduction 11-3 Canvases Overview 11-5 Creating a Stacked Canvas 11-7 Creating a Toolbar 11-13 Creating a Tab Canvas 11-17 Summary 11-25 Practice 11 Overview 11-27 Practice 11 11-28 Lesson 12: Introduction to Triggers Introduction 12-3 What Is a Trigger? 12-5 Trigger Components 12-7 Summary 12-15 Lesson 13: Producing Triggers Introduction 13-3 Defining Triggers in Form Builder 13-5 PL/SQL Editor Features 13-9 Database Trigger Editor 13-11 Writing the Trigger Code 13-13

..................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I vii

Contents .....................................................................................................................................................

Adding Functionality Using Built-in Subprograms Using Triggers 13-27 Practice 13 Overview 13-32 Practice 13 13-33

13-19

Lesson 14: Debugging Triggers Introduction 14-3 Debugging Triggers 14-5 Summary 14-27 Practice 14 Overview 14-29 Practice 14 14-30 Lesson 15: Adding Functionality to Items Introduction 15-3 Item Interaction Triggers 15-5 Defining Functionality for Input Items 15-9 Defining Functionality for Noninput Items 15-13 Summary 15-27 Practice 15 Overview 15-29 Practice 15 15-30 Lesson 16: Runform Messages and Alerts Introduction 16-3 Run-time Messages and Alerts Overview 16-5 Built-ins and Handling Errors 16-7 Errors and Built-ins 16-9 Controlling System Messages 16-11 The FORM_TRIGGER_FAILURE Exception 16-15 Triggers for Intercepting System Messages 16-17 Creating and Controlling Alerts 16-21 Summary 16-31 Practice 16 Overview 16-33 Practice 16 16-34

..................................................................................................................................................... viii Oracle Forms Developer: Build Internet Applications I

Contents .....................................................................................................................................................

Lesson 17: Query Triggers Introduction 17-3 Query Triggers 17-5 SELECT Statements Issued During Query Processing WHERE and ORDER BY Clauses 17-9 Writing Query Triggers 17-11 Query Array Processing 17-15 Coding Triggers for Enter Query Mode 17-17 Overriding Default Query Processing 17-21 Obtaining Query Information at Run Time 17-25 Summary 17-29 Practice 17 Overview 17-31 Practice 17 17-32

17-7

Lesson 18: Validation Introduction 18-3 Validation Process 18-5 Using Object Properties to Control Validation 18-7 Controlling Validation by Using Triggers 18-11 Validating User Input 18-13 Tracking Validation Status 18-15 Built-ins for Validation 18-17 Summary 18-19 Practice 18 Overview 18-21 Practice 18 18-22 Lesson 19: Navigation Introduction 19-3 About Navigation 19-5 Controlling Navigation 19-7 Understanding Internal Navigation 19-11 Navigation Triggers 19-13 Using the When-New-“object”-Instance Triggers Using the Pre- and Post-Triggers 19-17

19-15

..................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I ix

Contents .....................................................................................................................................................

The Navigation Trap 19-19 Navigation in Triggers 19-21 Summary 19-23 Practice 19 Overview 19-25 Practice 19 19-26 Lesson 20: Transaction Processing Introduction 20-3 Transaction Processing 20-5 The Commit Sequence of Events 20-9 Characteristics of Commit Triggers 20-11 Common Uses for Commit Triggers 20-13 DML Statements Issued During Commit Processing 20-25 Overriding Default Transaction Processing 20-27 Running Against Data Sources Other than Oracle 20-31 Getting and Setting the Commit Status 20-33 Array Processing 20-39 Summary 20-43 Practice 20 Overview 20-45 Practice 20 20-46 Lesson 21: Writing Flexible Code Introduction 21-3 What Is Flexible Code? 21-5 Using System Variables for Flexible Coding 21-7 Using Built-in Subprograms for Flexible Coding 21-11 Referencing Objects by Internal ID 21-15 Referencing Items Indirectly 21-23 Summary 21-27 Practice 21 Overview 21-29 Practice 21 21-30

..................................................................................................................................................... x Oracle Forms Developer: Build Internet Applications I

Contents .....................................................................................................................................................

Lesson 22: Sharing Objects and Code Introduction 22-3 Reusable Objects and Code Overview 22-5 Property Class 22-7 Creating a Property Class 22-9 Inheriting a Property Class 22-11 Creating an Object Group 22-13 Copying and Subclassing Objects and Code 22-17 What Is an Object Library? 22-23 Working with Object Libraries 22-25 What Is a SmartClass? 22-27 Reusing PL/SQL 22-29 PL/SQL Libraries 22-31 Working with PL/SQL Libraries 22-33 Summary 22-37 Practice 22 Overview 22-39 Practice 22 22-40 Lesson 23: Introducing Multiple Form Applications Introduction 23-3 Multiple Form Applications 23-5 How to Start Another Form Module 23-7 Defining Multiple Form Functionality 23-9 Summary 23-21 Practice 23 Overview 23-23 Practice 23 23-24 Appendix A: Practice Solutions Practice 1 Solutions A-2 Practice 2 Solutions A-5 Practice 4-1 Solutions A-8 Practice 4-2 Solutions A-10 Practice 5 Solutions A-13 Practice 6 Solutions A-16

..................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I xi

Contents .....................................................................................................................................................

Practice 7 Solutions Practice 8 Solutions Practice 9 Solutions Practice 10 Solutions Practice 11 Solutions Practice 13 Solutions Practice 14 Solutions Practice 15 Solutions Practice 16 Solutions Practice 17 Solutions Practice 18 Solutions Practice 19 Solutions Practice 20 Solutions Practice 21 Solutions Practice 22 Solutions Practice 23 Solutions

A-22 A-25 A-27 A-32 A-33 A-41 A-43 A-44 A-46 A-48 A-50 A-52 A-54 A-58 A-60 A-63

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_IMAGE Description and Data B-13 S_INVENTORY Description and Data B-14 S_ITEM Description B-21 S_ITEM Data B-22 S_ORD Description and Data B-24 S_PRODUCT Description B-25 S_PRODUCT Data B-26

..................................................................................................................................................... xii Oracle Forms Developer: Build Internet Applications I

Contents .....................................................................................................................................................

S_REGION Description and Data B-30 S_TITLE Description and Data B-31 Oracle8 Objects: Types, Tables B-32 Appendix C: Oracle Rdb Overview What Is Oracle Rdb? C-2 Other Information C-4 Appendix D: Locking in Form Builder Locking D-5 Default Locking in Forms D-7 Locking in Triggers D-13 Summary D-19 Appendix E: Oracle8 Object Features Overview E-3 Oracle8 Datatypes E-5 Creating Oracle8 Objects E-11 Referencing Objects E-19 Displaying Oracle8 Objects in the Object Navigator E-21 Summary E-29 Appendix F: Using the Layout Editor Overview F-3 Why Use the Layout Editor? F-5 How to Access the Layout Editor F-7 Components of the Layout Editor F-9 Creating and Modifying Objects in the Layout Formatting Objects in the Layout F-19 Coloring Objects and Text F-21 Importing Images and Drawings F-25 Summary F-27

F-11

..................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I xiii

Contents .....................................................................................................................................................

Appendix G: Introduction to Query Builder What Is Query Builder? G-3 The Query Builder Window G-7 Building a New Query G-9 Datasource Components G-11 Refining a Query G-13 Viewing and Saving Queries G-17 Including Additional Tables G-19 Relationships G-23 Selecting Rows with Conditions G-29 Operators G-31 Entering Multiple Conditions G-33 Changing Conditions G-35 Defining Columns Using an Expression G-37 Defining Columns Using a Function G-39

..................................................................................................................................................... xiv Oracle Forms Developer: Build Internet Applications I

Preface .................................

Preface .....................................................................................................................................................

..................................................................................................................................................... xvi Oracle Forms Developer: Build Internet Applications I

Profile .....................................................................................................................................................

Profile Before You Begin This Course Before you begin this course, you should have the following qualifications: • Thorough knowledge of 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 - Using a graphical user interface (GUI) Prerequisites • The following instructor-led training (ILT) courses: - Introduction to Oracle: SQL & PL/SQL or Introduction to Oracle for Experienced SQL Users - Advanced SQL and SQL*Plus - Develop PL/SQL Program Units • Or the following CBTs from our SQL * PL/SQL CBT Library: - Oracle SQL and SQL*Plus: Basic SELECT Statements or Oracle SQL Specifics: Retrieving and Formatting Data - Oracle SQL and SQL*Plus: DDL and DML or Oracle SQL Specifics: Creating and Managing Database Objects - Oracle PL/SQL: Basics - Oracle SQL and SQL*Plus: Advanced SELECT Statements - Oracle SQL and SQL*Plus: SQL*Plus and Reporting - Oracle PL/SQL: Procedures, Functions and Packages - Oracle PL/SQL: Database Programming Suggested Follow-up Courses • Oracle Forms Developer: Build Internet Applications II • Oracle Reports Developer: Build Internet Reports • Oracle Forms Server: Deploy Internet Applications How This Course Is Organized Oracle Forms Developer: Build Internet Applications I is an instructor-led course featuring lecture and hands-on exercises. Online demonstrations and written practice sessions reinforce the concepts and skills introduced.

..................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I xvii

Preface .....................................................................................................................................................

Related Publications Oracle Publications Title Oracle Forms Developer Release 6i: Getting Started (Windows 95/NT) Oracle Forms Developer and Reports Developer Release 6i: Guidelines for Building Applications Oracle Forms Developer Release 6i: Deploying Forms Applications to the Web with Oracle Forms Server

Part Number A73154-01 A73073-01 A73071-01

Additional Publications • read.me files • relnotes.pdf file

..................................................................................................................................................... xviii Oracle Forms Developer: Build Internet Applications I

Typographic Conventions .....................................................................................................................................................

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

Courier new, case sensitive (default is lowercase)

Code output, directory names, filenames, passwords, pathnames, URLs, user input, usernames

Initial cap

Graphics labels (unless the term is a proper noun) Emphasized words and phrases, titles of books and courses, variables

Italic

Quotation marks

Uppercase

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 Can’t 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)

Do not save changes to the database. For further information, see Oracle7 Server SQL Language Reference Manual. Enter [email protected], 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.”

Use the SELECT command to view information stored in the LAST_NAME column of the EMP table.

..................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I xix

Preface .....................................................................................................................................................

Convention Arrow Brackets Commas

Element Menu paths Key names Key sequences

Plus signs

Key combinations

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 Code Convention Caps and lowercase Lowercase

Element Oracle Forms triggers Column names, table names Passwords PL/SQL objects

Lowercase italic Uppercase

Syntax variables SQL commands and functions

Example When-Validate-Item SELECT last_name FROM s_emp; DROP USER scott IDENTIFIED BY tiger; OG_ACTIVATE_LAYER (OG_GET_LAYER (’prod_pie_layer’)) CREATE ROLE role SELECT userid FROM emp;

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

..................................................................................................................................................... xx Oracle Forms Developer: Build Internet Applications I

Instructor Preface .................................

Instructor Preface .....................................................................................................................................................

Instructor Note General course information for instructors: PowerPoint Slides The slideshow provides many builds to enable you to step through your explanation. Of course, you can modify these builds if you prefer, and if you know how to use PowerPoint. Demonstrations An additional demonstration, start.fmb, is not mentioned in the course instructor notes but is included in the DEMO directory. You can deploy this form on the Web and use it to launch all other completed demonstrations provided in the course setup. This form contains a push button for each of the following demonstrations: • Lesson 4, explicit relationships: explrela.fmx • Lesson 11, windows and canvases: Win_demo.fmx • Lesson 12, execution hierarchy: EH.fmx • Lesson 14, using the debugger: DebugDemo.fmx • Lesson 15, simple hierarchical tree: HTreeDemo.fmx • Lesson 15, hierarchical tree with details: HTreeDemo2.fmx • Lesson 16, generic alert: Show_alert.fmx • Lesson 19, navigation: navigation.fmx • Lesson 21, set item property: SetFontDemo.fmx • Lesson 23, completed application: customers.fmx Practice Sessions Students might want to view the form output that they are asked to produce in each question. Solution files of all forms are available in the LAB_SOL directory. These files are named ORDWKXX.FMB and CUSTWKXX.FMB, where XX is the lesson number the solution file is for. The solution file for Lesson 1 is called summitwk.fmb.

..................................................................................................................................................... xxii Oracle Forms Developer: Build Internet Applications I

.....................................................................................................................................................

Instructor Note General setup information for instructors: Introduction Oracle Forms Developer and Oracle Forms Server are key components in Oracle’s Internet platform. To promote this message, approximately half of the practices for this course were modified for Web deployment. This section provides an overview of the recommended setup for this class with respect to Web deployment. Recommended Setup The recommended setup for this course implements a threetier architecture: • The client tier contains the Web browser where the application is displayed and used. • The middle tier is the application server where application logic and server software reside. • The database tier is the database server where enterprise data is stored. Note: Alternative setups are possible. For more information, refer to the manual Oracle Forms Developer Release 6i: Deploying Forms Applications to the Web with Oracle Forms Server. Forms Client With Internet applications, the user interface layer is loaded incrementally on the client in the form of a generic Java applet. This applet is also known as the Forms Client. The Forms Client has three primary functions: • To render the Forms Server application display for the user • To process user interaction back to the Forms Server efficiently • To process incoming messages from the Forms Server and translate them into interface objects for the end user efficiently To run a Java applet, you must install a Java Runtime Environment (JRE) on the client. The JRE may be a part of any Java-enabled Web browser, such as Netscape Navigator or Microsoft Internet Explorer, or it may be installed separately, such as an AppletViewer in a JavaSoft Java Development Kit (JDK). Oracle also offers a special client software product, Oracle JInitiator. JInitiator is an optimized plug-in to a Web browser to run a Forms Server application. JInitiator is implemented in the setup for this class.

..................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I xxiii

Instructor Preface .....................................................................................................................................................

Forms Server Oracle Forms Server is the middle tier application server for deploying Internet applications. The components of Oracle Forms Server and their basic responsibilities are: • Forms Server Listener, which initiates the Forms Server run-time session and makes a connection between the Forms Server Runtime Engine and the Forms Client. • Forms Server Runtime Engine, which manages application logic and processing. • Forms Web Common Gateway Interface (CGI), which dynamically creates an HTML page to be sent back to the user’s browser. The configuration of Oracle Forms Server and the associated files (registry.dat and formsweb.cfg) are not covered in this course. There are notes throughout the course that refer students to the course Oracle Forms Server: Deploy Internet Applications for more information. Web Listener In order to run Forms applications on the Web, a Web listener is required on the middle tier in addition to Oracle Forms Server. The Web listener services requests from the client to run a Forms application. Oracle WebDB Listener, a lightweight Web listener that supports CGI and is provided with Oracle Forms Server, is implemented in the setup for this class. The configuration of the WebDB Listener is not covered in this class. Steps to Deploy Forms Applications on the Web 1 Configure the WebDB Listener. This is done for you in the setup. 2 Configure the Forms Server environment variables. This is done for you in the setup. 3 Start the Forms Server Listener. This should be done for you in the setup. To verify that the Forms Server Listener is running, do the following: – From the Windows NT task bar, click the Start button and select Run. – Enter taskmgr. – Click the Processes tab. – Click the Image Name column button twice to put the processes’ names in ascending order. – Verify that the ifsrv60.exe process appears. – Verify that at least one instance of ifweb60.exe appears.

..................................................................................................................................................... xxiv Oracle Forms Developer: Build Internet Applications I

.....................................................................................................................................................

Steps to Deploy Forms Applications on the Web (continued) If these two processes are not running, start the Forms Server Listener from the Windows NT task bar: – Click the Start button and select Run. – Enter ifsrv60 -listen. – Click OK. 4 Generate the Forms application executable. 5 Deploy the Forms application on the Web. Double-click the shortcut on your desktop for Run a Form on the Web. If there is no shortcut, you can invoke the Web Forms Tester from the Windows NT task bar: – Click the Start button and select Programs. – Select Oracle Forms 6i. – Select Run a Form on the Web. In the Web host field, specify the name of the middle-tier machine where Forms Server and WebDB Listener are running. In the Web port field, specify a port number for the WebDB Listener. This information is specific to each site. You can create a bookmark for this location: – Click the Bookmarks button. – Select Add Bookmark. Run a form by entering the name of your executable file for the Form parameter and the information to connect to the database for the Userid parameter. Click the Run Form button. Note: The Run Form Web button in Form Builder will not be functional if the recommended setup for this class is implemented. According to the release notes for Forms Developer 6i, Forms Server must be installed on the client machine in order for this button to be operational.

..................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I xxv

Instructor Preface .....................................................................................................................................................

..................................................................................................................................................... xxvi Oracle Forms Developer: Build Internet Applications I

I ................................

Introduction

Introduction ......................................................................................................................................................

Objectives

After completing this lesson, you should be able to do the following:

• •

Identify the course objectives Identify the course content and structure

Copyright  Oracle Corporation, 2000. All rights reserved.

Schedule Topic Lecture

Timing 15 minutes

Total

15 minutes

..................................................................................................................................................... I-2 Oracle Forms Developer: Build Internet Applications I

Overview .....................................................................................................................................................

Overview Introduction This lesson introduces you to the Oracle Forms Developer: Build Internet Applications I course: the objectives that the course intends to meet, the topics that it covers, and how the topics are structured over the duration of the course.

..................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I I-3

Introduction ......................................................................................................................................................

Release 6i Curriculum 5 days

Oracle Forms Developer: Build Internet Applications I Form Builder Library

3 days

Oracle Reports Developer: Build Internet Reports

5 days

Report Builder Library

Oracle Forms Developer: Build Internet Applications II Form Builder Library

2 days

Oracle Forms Server: Deploy Internet Applications

Oracle Reports Server: Deploy Internet Applications

2 days

ILT CBT

Copyright  Oracle Corporation, 2000. All rights reserved.

Course Objectives After completing this course, you should be able to do the following:



Describe the capabilities of Oracle Forms Developer Form Builder



Create form modules including components for database interaction and GUI controls



Display form modules in multiple windows and a variety of layout styles



Implement triggers to:





Enhance functionality



Communicate with users



Supplement validation, control navigation, and modify default transaction processing

Reuse objects and code Copyright  Oracle Corporation, 2000. All rights reserved.

..................................................................................................................................................... I-4 Oracle Forms Developer: Build Internet Applications I

Course Objectives .....................................................................................................................................................

Course Objectives Course Description In this course, participants will build, test, and deploy interactive Internet applications. Working in a graphical user interface (GUI) environment, participants will learn how to create and customize forms with user input items such as check boxes, list items, and radio groups. They will also learn how to modify data access by creating event-related triggers.

..................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I I-5

Introduction ......................................................................................................................................................

Course Content

Day 1

• • •

Lesson 1

Course Introduction

Lesson 2

Running a Form Builder Application

Lesson 3

Working in the Form Builder Environment



Lesson 4

Creating a Basic Form Module

Copyright  Oracle Corporation, 2000. All rights reserved.

Course Content

Day 2

• • • •

Lesson 5

Working with Data Blocks and Frames

Lesson 6

Working with Text Items

Lesson 7

Creating LOVs and Editors

Lesson 8

Creating Additional Input Items

Copyright  Oracle Corporation, 2000. All rights reserved.

..................................................................................................................................................... I-6 Oracle Forms Developer: Build Internet Applications I

Course Content .....................................................................................................................................................

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

Lesson Name

1

Course Introduction

2

Running a Form Builder Application

3

Working in the Form Builder Environment

4

Creating a Basic Form Module

Day 2 Lesson Number

Lesson Name

5

Working with Data Blocks and Frames

6

Working with Text Items

7

Creating LOVs and Editors

8

Creating Additional Input Items

..................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I I-7

Introduction ......................................................................................................................................................

Course Content

Day 3

• •

Lesson 9

Creating Non-Input Items

Lesson 10

Creating Windows and Content Canvases

• • • •

Lesson 11 Working with Other Canvases Lesson 12 Introduction to Triggers Lesson 13 Producing Triggers Lesson 14 Debugging Triggers

Copyright  Oracle Corporation, 2000. All rights reserved.

Course Content

Day 4

• • • • •

Lesson 15

Adding Functionality to Items

Lesson 16

Runform Messages and Alerts

Lesson 17

Query Triggers

Lesson 18

Validation

Lesson 19

Navigation

Copyright  Oracle Corporation, 2000. All rights reserved.

..................................................................................................................................................... I-8 Oracle Forms Developer: Build Internet Applications I

Course Content .....................................................................................................................................................

Day 3 Lesson Number 9

Lesson Name

Creating Non-Input Items

10

Creating Windows and Content Canvases

11

Working with Other Canvases

12

Introduction to Triggers

13

Producing Triggers

14

Debugging Triggers

Day 4 Lesson Number

Lesson Name

15

Adding Functionality to Items

16

Runform Messages and Alerts

17

Query Triggers

18

Validation

19

Navigation

..................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I I-9

Introduction ......................................................................................................................................................

Course Content

Day 5

• • • •

Lesson 20

Transaction Processing

Lesson 21

Writing Flexible Code

Lesson 22

Sharing Objects and Code

Lesson 23

Introducing Multiple Form Applications

Copyright  Oracle Corporation, 2000. All rights reserved.

..................................................................................................................................................... I-10 Oracle Forms Developer: Build Internet Applications I

Course Content .....................................................................................................................................................

Day 5 Lesson Number

Lesson Name

20

Transaction Processing

21

Writing Flexible Code

22

Sharing Objects and Code

23

Introducing Multiple Form Applications

..................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I I-11

Introduction ......................................................................................................................................................

..................................................................................................................................................... I-12 Oracle Forms Developer: Build Internet Applications I

1 ................................

Introduction to Oracle Forms Developer and Oracle Forms Server

Lesson 1: Introduction to Oracle Forms Developer and Oracle Forms Server ......................................................................................................................................................

Objectives

After completing this lesson, you should be able to do the following:



Describe Oracle Forms Developer and Oracle Forms Server components

• • • • •

Describe the architecture of Oracle Forms Server Describe Form Builder components Navigate around the builder interface Customize the Oracle Forms Developer session Describe the course application

Copyright  Oracle Corporation, 2000. All rights reserved.

Schedule Topic Lecture Practice Total

Timing 30 minutes 25 minutes 55 minutes

...................................................................................................................................................... 1-2 Oracle Forms Developer: Build Internet Applications I

Introduction ......................................................................................................................................................

Introduction Overview This course teaches you how to build effective and professional form applications using Oracle Forms Developer. This lesson identifies the key features of Oracle Forms Developer, Oracle Forms Server, and the course application model and contents.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 1-3

Lesson 1: Introduction to Oracle Forms Developer and Oracle Forms Server ......................................................................................................................................................

Internet Computing Solutions Application Type and Audience

Product Approach

Oracle Products

Enterprise applications, Business developers

Repository-based modeling & generation, Declarative

Oracle Designer, Oracle Forms Developer, & Oracle Forms Server

Java components, Component developers

Two-way coding, Java and JavaBeans

Oracle JDeveloper Oracle Application Server

Self-service applications & content management, Web site developers

Browser-based, Dynamic HTML

Oracle WebDB Oracle Database Server

Reporting and analytical applications, MIS & business users

Dynamic Web reporting, Drill, slice & dice, Forecasting

Oracle Reports Developer, Oracle Reports Server, Oracle Discoverer, & Oracle Express

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note In this course, several slides, such as the one above, have builds or animation associated with them. These are created to enhance the explanation of several key concepts. As you show these slides to the students, each new concept will build one at a time, until all of the builds are displayed.

...................................................................................................................................................... 1-4 Oracle Forms Developer: Build Internet Applications I

Internet Computing Solutions ......................................................................................................................................................

Internet Computing Solutions Oracle offers a range of tools and deployment options for Internet computing. Different types of developers and different types of applications require different toolsets. Enterprise application developers need a declarative model-based approach. Oracle Designer and Oracle Forms Developer provide this solution, using Oracle Forms Server as the primary deployment option. Component developers need different tools and methods. For these developers, Java is the language of choice. Oracle’s solution is JDeveloper. For Web site developers and content publishers who want to build self-service, dynamic Hypertext Markup Language (HTML) applications for Web sites, the approach is different. Oracle WebDB provides an easy-to-use development environment that resides entirely inside an Oracle8i database. WebDB provides a browser-based environment from development through deployment of an application. For Management Information System (MIS) developers and end users, there is the Oracle Business Intelligence toolset. Oracle Reports Developer, Oracle Reports Server, Oracle Discoverer, and Oracle Express provide the whole range for reporting, analysis, and trending facilities. This course focuses on how you can rapidly build scalable, high-performance applications for the Internet by using Oracle Forms Developer.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 1-5

Lesson 1: Introduction to Oracle Forms Developer and Oracle Forms Server ......................................................................................................................................................

What Is Oracle Forms Developer?

A productive development environment for Internet business applications – Data entry – Query screens

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 1-6 Oracle Forms Developer: Build Internet Applications I

What Is Oracle Forms Developer? ......................................................................................................................................................

What Is Oracle Forms Developer? Oracle Forms Developer is a productive development environment for building enterprise-class, scalable database applications for the Internet. Oracle Forms Developer provides a set of tools that enable business developers to easily and quickly construct sophisticated database forms and business logic with a minimum of effort. Oracle Forms Developer uses powerful declarative capabilities to rapidly create applications from database definitions that leverage the tight integration with Oracle8i. The toolset leverages Java technology, promotes reuse, and is designed to allow developers to declaratively build rich user interfaces. Developer productivity is further increased through a single integrated development environment that enables distributed debugging across all tiers, utilizing the same PL/ SQL language for both server and client. Oracle Forms Developer’s tight integration with Oracle Designer enables you to use a productive model-driven development approach. Oracle Forms Developer applications can be automatically generated from business requirements designed in the Oracle Designer modeling environment. These models are stored in the Oracle Repository. Code-level changes made within the Oracle Forms Developer environment can be automatically reverse engineered back into the models, preserving the integrity between the models and the application.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 1-7

Lesson 1: Introduction to Oracle Forms Developer and Oracle Forms Server ......................................................................................................................................................

What Is Oracle Forms Server?

An optimized application server for business applications with a Java front end

Oracle Forms Server

Any Web server

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 1-8 Oracle Forms Developer: Build Internet Applications I

What Is Oracle Forms Server? ......................................................................................................................................................

What Is Oracle Forms Server? Oracle Forms Server is an optimized application server platform for delivering Oracle Forms Developer applications to the Internet. Oracle Forms Server automatically provides the infrastructure needed to successfully deliver applications on the Internet through built-in services and optimizations. Oracle Forms Server uses a three-tier architecture to deploy database applications: • The client tier contains the Web browser, where the application is displayed and used. • The middle tier is the application server, where the application logic and server software reside. • The database tier is the database server, where enterprise data is stored.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 1-9

Lesson 1: Introduction to Oracle Forms Developer and Oracle Forms Server ......................................................................................................................................................

Oracle Forms Server Architecture

Forms Server

Java forms

Oracle8i or other database

Web server

Copyright  Oracle Corporation, 2000. All rights reserved.

Forms Server Web browser

Oracle Forms Server

Database

Forms Server User interface layer

Incrementally downloaded User interface layer

Java applet

Application logic

SQL*Net

Data Manager and PL/SQL engine

FMX File

Application executable

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 1-10 Oracle Forms Developer: Build Internet Applications I

Forms Server Architecture ......................................................................................................................................................

Forms Server Architecture Oracle Forms Server is a middle-tier application server for deploying complex, transactional forms applications to the Internet. Forms Server consists of three major components: the Java client, the Forms Listener, and the Forms Runtime Engine. • Java client: The Java client is an applet that is downloaded at run time from an application server to an end user’s Web browser. The Java client displays the forms’s user interface and manages interaction between end users and the Forms Server. • Forms Listener: The Forms Listener initiates the Forms Server run-time session and establishes a connection between the Forms client and the Forms Server Runtime Engine. The listener can also maintain a pool of run-time engines ready for connection, making connection time from the Java client complete as quickly as possible. • Forms Runtime Engine: The Forms Runtime Engine manages application logic and application processing. It is also the process that maintains a connection to the database on behalf of the Java client. The code run by the Forms Server Runtime Engine is the same code—form, menu, and library modules—used for running in a client-server implementation on the same platform. No application code changes are required to deploy an application to the Internet. When a user runs a forms session over the Web, a thin, Java-based Forms applet is dynamically downloaded from the application server and automatically cached on the Java client machine. The same Java applet code can be used for any form, regardless of size and complexity. Instructor Note See Deploying Forms Applications to the Web with Oracle Forms Server Release 6i for additional information on the Forms Server.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 1-11

Lesson 1: Introduction to Oracle Forms Developer and Oracle Forms Server ......................................................................................................................................................

Key Features • • • • • • •

Comprehensive GUI support Distributed applications Tools for rapid application development Application partitioning Flexible source control Extended scalability Object reuse

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 1-12 Oracle Forms Developer: Build Internet Applications I

Oracle Forms Developer Key Features ......................................................................................................................................................

Oracle Forms Developer Key Features Oracle Forms Developer provides a number of features that contribute to the strength and flexibility of the product. Comprehensive GUI Support Oracle Forms Developer supports the native features of Microsoft Windows 95 and NT 4.0, and it provides portability to Motif and character-mode production environments. Distributed Applications The tools provide local, client-server, and Web support with multiple database connections per application. In addition to Oracle7 and Oracle8, your applications can access Structured Query Language (SQL) databases through open database connectivity (ODBC). Tools for Rapid Application Development Oracle Forms Developer provides the tools that simplify many development tasks, enabling you to create and modify applications with little or no code. Productivity is enhanced with Oracle Forms Developer’s wizard-based rapid application development and built-in commands that perform common functions. Application Partitioning You can place individual PL/SQL program units on the database server, the application server, or in the client-side application, whichever is most suitable in each case. You can copy and move objects between modules and the database server by using convenient drag-and-drop techniques. Flexible Source Control You can store the definitions of your application modules in flat files or in the Oracle database. You can perform version control on these modules and produce documentation by using Oracle Forms Developer facilities. Extended Scalability You can scale applications from single users to tens of thousands, with no changes to the application. Scalability is inherent in the multitiered architecture of the product. There is support for server functionality, such as array DML, database cursors, bind variables, and result sets. Object Reuse Oracle Forms Developer offers an inheritance model that facilitates the inheritance of attributes and code from one object to another and from one application to another, through subclassing and object libraries.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 1-13

Lesson 1: Introduction to Oracle Forms Developer and Oracle Forms Server ......................................................................................................................................................

Form Builder Components

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Mention these briefly. We will start Form Builder and see the interface in a demonstration later in this course.

...................................................................................................................................................... 1-14 Oracle Forms Developer: Build Internet Applications I

Form Builder Components ......................................................................................................................................................

Form Builder Components Introduction Form Builder is the main application-building component of Oracle Forms Developer. The interface components of Form Builder help to provide the flexibility and productivity of the Oracle Forms Developer development environment. Object Navigator The Object Navigator is a hierarchical browsing and editing interface that enables you to locate and manipulate application objects quickly and easily. Features include: • A hierarchy represented by indentation and expandable nodes. (Top-level nodes show module types, database objects, and built-in packages. All other nodes and the objects they contain are indented to indicate that they belong to these higher level nodes.) • Find field and icons, enabling forward and backward searches for any level of node or for an individual item in a node. • Icons in the vertical toolbar replicating common File menu functions. • An icon next to each object to indicate the object type. Property Palette All objects in a module, including the module itself, have properties that you can see and modify in the Property Palette. Features include: • Copy and reuse properties from another object • Find field and icons, similar to Object Navigator

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 1-15

Lesson 1: Introduction to Oracle Forms Developer and Oracle Forms Server ......................................................................................................................................................

Form Builder Layout Editor

Toolbar

Tool Palette

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note It is important for the students to gain exposure to the Object Navigator and the Layout Editor in Form Builder. They will need this knowledge to complete the practice exercise at the end of this lesson. Demonstration • Open an existing form, and briefly explain the features of the Object Navigator. • Go to the Layout Editor. Point out the major tools in the Toolbar. Demonstrate some of the major tools in the Tool Palette. • Draw a rectangle and an ellipse, and also show how to draw a square and a circle by holding down the [Shift] key when using the rectangle and ellipse tools. • Demonstrate selecting more than one object at the same time, and show how to group various objects. • Demonstrate resizing, moving, aligning, coloring, and deleting objects. • Demonstrate using the Text tool and changing the font style and size. • Demonstrate how to pin a tool by double-clicking a tool.

...................................................................................................................................................... 1-16 Oracle Forms Developer: Build Internet Applications I

Form Builder Components ......................................................................................................................................................

Layout Editor (or Layout Model) The Layout Editor is a graphical design facility for creating and arranging interface items and graphical objects in your application. When you use the Tool Palette and the Toolbar available in the Layout Editor, you can design the style, color, size, and arrangement of visual objects in the application. The layout can include graphical objects and bitmapped images when running in a GUI environment. PL/SQL Editor The PL/SQL Editor is the integrated functionality of Oracle Procedure Builder that exists within the Form Builder. It provides: • Development of triggers, procedures, functions, and packages in Oracle Forms Developer as well as the database • Development of libraries to hold PL/SQL program units • Statement-level debugging of PL/SQL at run time

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 1-17

Lesson 1: Introduction to Oracle Forms Developer and Oracle Forms Server ......................................................................................................................................................

Oracle Toolkit and Multimedia Applications Forms

1 2 3 4

Microsoft Windows 95 Windows NT

Character mode

OSF/Motif Copyright  Oracle Corporation, 2000. All rights reserved.

1

Oracle Forms Developer

2

Multimedia extension

3

Toolkit

4

Base functionality

Instructor Note ActiveX controls are reusable components that can be embedded in a Form Builder application. Form Builder acts as an ActiveX control container. The course Oracle Forms Developer: Build Internet Applications II discusses the use of ActiveX controls.

...................................................................................................................................................... 1-18 Oracle Forms Developer: Build Internet Applications I

Oracle Toolkit and Oracle Multimedia ......................................................................................................................................................

Oracle Toolkit and Oracle Multimedia Oracle Toolkit is a library of functions that perform user interface events, such as control of the scroll bar and menu activation. Together with Oracle Multimedia, which provides the integration of images, sounds, and other media facilities, Toolkit underlays Oracle Forms Developer, bridging the gap between your Oracle Forms Developer applications and the native environment in which you are working. As your applications request facilities, such as opening a window or displaying a menu, Oracle Forms Developer passes the requests to Toolkit, which communicates them to the native platform. Toolkit attempts to pass tasks to the native interface, if that interface can handle them, so that your application uses the natural features of your environment, wherever possible. This means that an Oracle Forms Developer application looks and behaves like a Windows NT application when running on Windows NT, and like a Motif application if moved to this platform. Toolkit itself provides the functionality where certain functionalities are not available through the native interface, for example, on character mode devices. This provides an adaptable user interface for your Oracle Forms Developer applications. Note: You can see a list of these and other products that support the common components and integration of Oracle Forms Developer by selecting Help—>About in the Form Builder menu. Web Design Tip ActiveX, OCX, OLE, and VBX: Third party controls that display screen output on the application server are not supported in a form deployed to the Web because users cannot view the output. Equivalent functionality can be obtained by using JavaBeans and pluggable Java components (PJCs) in Internet applications.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 1-19

Lesson 1: Introduction to Oracle Forms Developer and Oracle Forms Server ......................................................................................................................................................

Getting Started • • • •

Start Form Builder. See the Welcome page with several options. Connect to the database. Select File—>Connect.

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Invoke Form Builder. Open an existing form. Use one of the forms from the existing prebuilt application. We use an existing form in this lesson to familiarize students with the Oracle Forms Developer interface. Later we create new forms by using the wizards. Form Builder will probably prompt you to connect to the database when it tries to run the form. Also show students the File—>Connect menu option.

...................................................................................................................................................... 1-20 Oracle Forms Developer: Build Internet Applications I

Getting Started in the Oracle Forms Developer Interface ......................................................................................................................................................

Getting Started in the Oracle Forms Developer Interface Starting Form Builder To start Form Builder, invoke it from the Forms Developer 6i group. What You See in the Builders When you invoke Form Builder, you first see the Welcome page giving you several options, including: • Create a new module by using the Data Block Wizard • Create a new module manually • Open an existing module Database Connection If you build applications that access database objects, you need to connect to a database account from the Form Builder. Connect to a database if you need to: • Compile code that contains SQL • Access database objects in the Object Navigator • Create Oracle Forms Developer objects that are based on database objects How to Connect to Oracle 1 Select File—>Connect from the menu. 2 Enter the database user and password in the Connect dialog box. If not connecting to the default database, also provide the necessary connect string or database alias. Note: Oracle Forms Developer automatically displays the Connect dialog box if you try to perform a task that requires connection.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 1-21

Lesson 1: Introduction to Oracle Forms Developer and Oracle Forms Server ......................................................................................................................................................

Main Menu Structure

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Show the Main menu options, and how they differ in context. Switch between Object Navigator and Layout Editor. The Navigator menu option is replaced with the Format and Arrange options while in the Layout Editor. Do not describe Help in detail; there are more details for these options later in this lesson.

...................................................................................................................................................... 1-22 Oracle Forms Developer: Build Internet Applications I

Navigating Around the Form Builder Main Menu ......................................................................................................................................................

Navigating Around the Form Builder Main Menu Introduction The Main menu contains options to enable you to create, modify, and manage your form modules. Common Menu Features The following table describes some common features in GUI menus. Feature

Description

Underline

Shortcut key: [Alt] + letter

Ellipsis ( . . . )

Additional input, usually by using a dialog box

>

Menu option has a submenu

Windows menu

List of open windows; select any window to make it active

Help

List of help facilities, such as online help text, Cue Cards, Quick Tour

Native GUI Interface The menu example here is shown in Windows NT. However, menus appear with the same look and feel of your native GUI interface. For example, in Motif, the Windows Print Dialog options appear as submenus of the Font menu. Form Builder Main Menu Menu Item

Description

File

Common file utilities, such as open, save, connect, administration

Edit

Cut, copy, paste, and so on

View

Switch view in current window; options vary greatly depending on context

Navigator

Only appears in Object Navigator; includes expand, collapse, bookmark

Program

Includes compilation and access to PL/SQL editors

Tools

Includes wizards and preferences

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 1-23

Lesson 1: Introduction to Oracle Forms Developer and Oracle Forms Server ......................................................................................................................................................

Customizing Your Oracle Developer Session

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 1-24 Oracle Forms Developer: Build Internet Applications I

Customizing Your Oracle Forms Developer Session ......................................................................................................................................................

Customizing Your Oracle Forms Developer Session What Are Oracle Forms Developer Tools Preferences? You can use tools preferences to customize some aspects of your Oracle Forms Developer builder session. Form Builder Preferences There are four tab pages in the Form Builder Preferences dialog box. Press the Help key ([F1] for Windows NT/95) in the Preferences dialog to see a description of each preference. As well as session preferences, Form Builder preferences enable you to set run-time settings when running your form within the builder. The table describes a few example form preferences. Tab

Preference Name

Description

General

Build Before Running

Determines whether Form Builder automatically compiles the active module when you run a form. This option enables you to avoid issuing separate Compile and Run commands each time you modify and run a form.

Access

Access

Determines if form definitions are saved to (or opened from) the database or from files, or both. If access is set to both, Form Builder prompts you when you save or open each form.

Wizards

Welcome Dialog

Check box to suppress or display the first Welcome dialog box. There are several similar check boxes.

Runtime

Array Processing

Determines whether Form Builder processes groups of records at a time, reducing network traffic and increasing performance.

How to Modify Tools Preferences 1 Select Tools—>Preferences. 2 Select the option you require. 3 Click OK to save changes, or Cancel to cancel changes.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 1-25

Lesson 1: Introduction to Oracle Forms Developer and Oracle Forms Server ......................................................................................................................................................

Saving Tools Preferences

1

2

3

Copyright  Oracle Corporation, 2000. All rights reserved.

1

Existing preferences file

2

Modified preferences

3

Updated, merged preferences file

...................................................................................................................................................... 1-26 Oracle Forms Developer: Build Internet Applications I

Saving Tools Preferences ......................................................................................................................................................

Saving Tools Preferences When you click OK in the Preferences dialog box, Oracle Forms Developer updates your current session with the changes. When you exit the builder, Oracle Forms Developer writes the changes to a preference file for future sessions. Oracle Forms Developer and Oracle Reports Developer share the same preference file. If the preference file already exists, Oracle Forms Developer merges its changes with the existing file. This means that preferences for Reports are not affected. Each option in the preference file is prefixed by the tool name to which it belongs. Example Reports.Object_Access = File Forms.build_before_run = on Forms.welcome_dialog = on

Oracle Forms Developer reads the preference file whenever you invoke Form Builder. Oracle Reports Developer reads the preference file whenever you invoke Report Builder. The name of the preference file varies on different platforms: Window Manager

Preference Filename

Microsoft Windows

cauprefs.ora

Motif

prefs.ora

Note: The preferences file is an editable text file. However, we recommend that, where possible, you alter the options in the Preferences dialog box.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 1-27

Lesson 1: Introduction to Oracle Forms Developer and Oracle Forms Server ......................................................................................................................................................

Oracle Forms Developer Environment Variables • • •

FORMS60_PATH UI_ICON ORACLE_PATH

Windows NT: Modify in Registry (REGEDIT.EXE or REGEDT32.EXE)

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Warn students to take care when modifying these variables, because they immediately affect the environment and mistakes can prevent applications from running. Whenever possible later in the course, point out when these variables are used, and remind students to avoid hardcoding pathnames in to their applications. Oracle Forms Developer also searches the local working directory.

...................................................................................................................................................... 1-28 Oracle Forms Developer: Build Internet Applications I

Oracle Developer Environment Variables ......................................................................................................................................................

Oracle Developer Environment Variables Introduction Oracle Forms Developer uses many environment variables. These have default values, all of which you can modify in your own environment for different applications. In this section, we discuss only those variables that relate to file searching at run time. Setting Pathnames Form Builder uses some environment variables to search for files at run time. This enables you to build applications that are portable across platforms and directory structures, by avoiding hardcoded paths in file references within a form. Variable

Description

FORMS60_PATH

A path that Form Builder searches for files at run time

UI_ICON

A path that all builders search for icon files at run time

Generic Oracle Path ORACLE_PATH is an additional path that Form Builder searches if it cannot find a file in the specific path. Modifying Environment Variables In a Windows NT 32-bit environment, use the Windows Registry to modify these paths.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 1-29

Lesson 1: Introduction to Oracle Forms Developer and Oracle Forms Server ......................................................................................................................................................

Environment Variables and Y2K Compliance • •

NLS_DATE_FORMAT FORMS60_USER_DATE_FORMAT

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 1-30 Oracle Forms Developer: Build Internet Applications I

Environment Variables and Y2K Compliance ......................................................................................................................................................

Environment Variables and Y2K Compliance Dates in Oracle Forms Developer Dates in Oracle Forms Developer applications can come from several sources: • Fetched from the server/database • Entered by the end user • Defined in the application itself Date Format Masks In a later lesson, you will learn how to specify a format mask for a date item in your form. In addition to the format masks a developer might explicitly specify, Form Builder uses a number of its own internal masks. The values for these internal masks can be specified with property values and environment variables. To eliminate potential errors caused by the year 2000 (Y2K), you can set two environment variables that Form Builder uses to format date items: • Database date format mask: Each database session within a Forms application has a single database date format mask. A default value for this mask is established by the Oracle server’s initialization parameter. You can override this value in each new database session for a particular client by setting the client’s NLS_DATE_FORMAT environment variable. • Input date format mask: This mask (potentially, a set of masks) is used to convert a user-entered string into a native format date value. You can set the environment variable, FORMS60_USER_DATE_FORMAT, to specify these format masks. Example Environment Variable

Value

FORMS60_USER_DATE_FORMAT

FXFMDD-MM-RRRR

This would force the user to enter values into date items (with no specified format mask) in the format exemplified by 31-6-97. The RRRR token enables years between 1950 and 2049 to be entered with the century omitted. Note: For more information on date handling in Oracle Forms Developer, consult the online Help in Form Builder and the Oracle Forms Developer 6i Online Manuals.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 1-31

Lesson 1: Introduction to Oracle Forms Developer and Oracle Forms Server ......................................................................................................................................................

Using the Online Help System •

Quick Tour: Built-in CBT package of technical information



Cue Cards: Simple step-by-step instructions

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 1-32 Oracle Forms Developer: Build Internet Applications I

Invoking Online Help Facilities ......................................................................................................................................................

Invoking Online Help Facilities Oracle Forms Developer Help Options The table describes the Help menu options in Form Builder. Help Menu Option

Description

Form Builder Help Topics

This is the contents page for comprehensive online help. Includes Index and Find tabs. The Help key ([F1] (for Windows NT/95) displays context-sensitive online help at any place in the builder.

Quick Tour

This built-in computer-based training package is more detailed than the Cue Cards, including technical explanations of the Form Builder components.

Cue Cards

These appear as separate windows that give simple step-by-step instructions and examples to help novice users learn basic functionality.

Manuals

This provides an index to installed online manuals, which are HTML files that you can view with any browser.

About Form Builder

This is a separate window that shows product components and their version numbers. When you are connected to a database server, it also displays similar information for server-side product components.

Most of the Help features are optional extras during product installation and require additional resources.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 1-33

Lesson 1: Introduction to Oracle Forms Developer and Oracle Forms Server ......................................................................................................................................................

Summit Sporting Goods Schema

s_ord

s_item

s_customer

s_inventory

s_product

s_image

s_emp

s_dept

s_warehouse

s_region

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 1-34 Oracle Forms Developer: Build Internet Applications I

Introducing the Course Application ......................................................................................................................................................

Introducing the Course Application The Summit Sporting Goods Schema The simplified table diagram shows the tables that we use throughout this course, to build our form application. Some of you will be familiar with these tables from other Oracle courses. Summit Sporting Goods is a company supplying sports goods to customers. Summit has a number of employees in several departments. Some employees are sales representatives who have a relationship to specific customers. Customers place orders. Each order consists of one or more line items. Each line item represents a product. Each product has an image associated with it, in the form of an image file. The company products are stored in a number of warehouses. The contents of the warehouses are managed in the inventory.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 1-35

Lesson 1: Introduction to Oracle Forms Developer and Oracle Forms Server ......................................................................................................................................................

Summit Application CV_Customer Canvas S_CUSTOMER Table

S_ORD Table S_ITEM Table

S_CUSTOMER Block

Customers Form

CV_Order Canvas S_ORD Block S_ITEM Block

Orders Form

CV_Inventory Canvas S_Inventory Block

S_INVENTORY Table Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 1-36 Oracle Forms Developer: Build Internet Applications I

Introducing the Course Application ......................................................................................................................................................

The Summit Sporting Goods Application The following example Form Builder application will familiarize you with the main run-time facilities of the product. You will also build your own version of this application during the workshops in the course. The Summit company produces a range of sporting goods, which they sell to sports stores (their customers). The Summit application is an order-entry system that maintains customer details, their orders, and the available stock (inventory). The application consists of two main forms: • CUSTOMERS form: Facilitates queries on existing customers and the insertion, update, or deletion of customer records. When a customer is selected, the user can open the ORDERS form to enter or view orders for that customer. S_CUSTOMER block: A single record block, whose base table is S_CUSTOMER. • ORDERS form: Opened from the CUSTOMER form, the ORDERS form displays orders for a customer and the line items that belong to each order. Orders may also be created, modified, or deleted in this form. You can also display the stock available on the ordered products. - S_ORD block: A single record master block for the form (The base table is S_ORD, but the block also displays associated information from other tables, such as the name of the customer.) - S_ITEM block: The related detail block for an order, showing its line items and the products ordered (This is a multirecord block whose items are on the same canvas as those in the S_ORD block. The ITEM block’s base table is S_ITEM, but it also displays information from other tables, such as the product name and standard price.) - S_INVENTORY block: A multirecord block showing warehouse stock for a product (Its items are on a separate canvas, which is assigned to its own window. This block is linked to the current product in the S_ITEM block, but the two blocks can operate independently.)

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 1-37

Lesson 1: Introduction to Oracle Forms Developer and Oracle Forms Server ......................................................................................................................................................

Summary • • • • •

Oracle Forms Developer features Oracle Forms Server components Builder interface Builder preferences The Summit course application

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 1-38 Oracle Forms Developer: Build Internet Applications I

Summary ......................................................................................................................................................

Summary •

• •

The Oracle Forms Developer provides a builder interface, including Object Navigator, Layout Editor, PL/SQL Editor, and Property Palette components, and offers a comprehensive online Help system. Oracle Forms Developer has a set of preferences that you can alter for the current and subsequent builder sessions. Finally, in this lesson we described the Summit application tables that we use throughout the course to build our forms.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 1-39

Lesson 1: Introduction to Oracle Forms Developer and Oracle Forms Server ......................................................................................................................................................

Practice 1 Overview

This practice covers the following topics:



Becoming familiar with the Object Navigator and Layout Editor



Modifing file access preferences

Copyright  Oracle Corporation, 2000. All rights reserved.

Note For solutions to this practice, see Practice 1 in Appendix A, “Practice Solutions.”

...................................................................................................................................................... 1-40 Oracle Forms Developer: Build Internet Applications I

Practice 1 Overview ......................................................................................................................................................

Practice 1 Overview This practice familiarizes you with Oracle Forms Developer by asking you a number of questions that you answer by navigating around the Form Builder interface. • Becoming familiar with the Layout Editor and Object Navigator in Form Builder • Modifying file access preferences Instructor Note This practice is intended to make students familiar and at ease with the interface. For additional help with the Layout Editor, refer them to Appendix F, Using the Layout Editor.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 1-41

Lesson 1: Introduction to Oracle Forms Developer and Oracle Forms Server ......................................................................................................................................................

Practice 1 1 Invoke Form Builder, and select “Open an existing form” from the 2 3

4

5 6 7 8 9

Welcome page. Open the Orders.fmb form module from the Open Dialog window. Change your preferences so that when you open or save a file, Form Builder gives you the option of saving the file to the file system or the database. Try to open the Customers.fmb form module. Notice that the module access dialog box is displayed. Click Cancel. Modify your preferences so that Form Builder will access the file system only. Close the ORDERS form. Open the Summit.fmb form module. Expand the Data Blocks node. Expand the Database Objects node. If you cannot expand the node, connect to the database and try again. What do you see below this node? Collapse the Data Blocks node.

...................................................................................................................................................... 1-42 Oracle Forms Developer: Build Internet Applications I

Practice 1 ......................................................................................................................................................

10 Change the layout of the Summit.fmb form module to match the

screen shot shown below. At the end, save your changes, and exit Form Builder.

a b c d e f g h i

Invoke the Layout Editor. Move the three summit shapes to the top-right corner of the layout. Align the objects along the bottom edge. Select the summit shape in the middle and place it behind the other two shapes. Draw a box with no fill around the summit shapes. Add the text Summit Sporting on top of the box. Move the Name, Id, and Region_Id items to match the screenshot. Move the First_Name item up to align it at the same level as the Last_Name item. Resize the scroll bar, to make it the same height as the three records in the Emp block. Save the form module, and exit Form Builder.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 1-43

Lesson 1: Introduction to Oracle Forms Developer and Oracle Forms Server ......................................................................................................................................................

...................................................................................................................................................... 1-44 Oracle Forms Developer: Build Internet Applications I

2 ................................

Running a Form Builder Application

Lesson 2: Running a Form Builder Application ......................................................................................................................................................

Objectives After completing this lesson, you should be able to do the following:

• • • • • • •

Describe application deployment environments Describe the run-time environment Navigate a Form Builder application Describe the two modes of operation Retrieve both restricted and unrestricted data Insert, update, and delete records Display database errors

Copyright  Oracle Corporation, 2000. All rights reserved.

Schedule Topic Lecture Practice Total

Timing 50 minutes 25 minutes 75 minutes

...................................................................................................................................................... 2-2 Oracle Forms Developer: Build Internet Applications I

Introduction ......................................................................................................................................................

Introduction Overview In this lesson, you will run an existing application both on the Web and in a clientserver environment in order to become familiar with the run-time interface of the Oracle Forms Developer. You must understand the form operator environment before designing and building your own applications.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 2-3

Lesson 2: Running a Form Builder Application ......................................................................................................................................................

Application Deployment •

Oracle Forms Server Web deployment



Oracle Forms Developer client-server environment

Copyright  Oracle Corporation, 2000. All rights reserved.

Web Form Tester

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 2-4 Oracle Forms Developer: Build Internet Applications I

Application Deployment ......................................................................................................................................................

Application Deployment Form Builder applications can be deployed to end users in a Web implementation or a client-server implementation. Web Implementation Deploying form applications to the Web is implemented by the three-tier architecture of Oracle Forms Server. Application logic and the Forms Server run-time engine reside on the middle-tier application server rather than on desktop client machines. All trigger processing occurs on database and application servers, while user interface processing occurs on the Forms client. In this course, you will use the Web form tester to deploy your form applications to the Web. Client-Server Implementation In this two-tier architecture, application logic and the Forms Server run-time engine reside on end users’ desktop machines. Although application logic can include database server-side triggers and logic, typically all user interface and trigger processing occurs on client machines.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 2-5

Lesson 2: Running a Form Builder Application ......................................................................................................................................................

Web Deployment: Run-Time Components

3 1

4

2

5 Copyright  Oracle Corporation, 2000. All rights reserved.

1

Browser window

2

Java applet

3

Default Menu

4

Menu toolbar

5

Console

Instructor Note Demonstration Launch Netscape Navigator. Run the Orders form on the Web by double-clicking the shortcut on your desktop for Run a Form on the Web. Enter orders.fmx for the Form parameter and enter a username, password, and connect string for the Userid parameter. Select the Run form button. Point out the Browser window, Java applet, Default menu, Menu toolbar, and Console components. Terminate this run-time session by exiting the form, and then closing the browser window. Be sure to advise students to always exit the form to terminate the applet before closing the browser window. Run the Orders form again using the Web form tester. This time, select Oracle for the Look and Feel parameter and Teal for the Color scheme parameter. Point out the rounded appearance of the buttons and the new look of the Menu toolbar.

...................................................................................................................................................... 2-6 Oracle Forms Developer: Build Internet Applications I

Web Deployment: What You See at Run Time ......................................................................................................................................................

Web Deployment: What You See at Run Time Starting a Run-Time Session A run-time session consists of one or more linked form and menu modules, all under the control of a single user. To start a Forms run-time session on the Web, you simply have to point your browser to a uniform resource locator (URL) that corresponds to a Hypertext Markup Language (HTML) file. The HTML file contains all necessary tags, parameters, and parameter values required to run the selected Forms application on the Web. The following sequence of events occurs: 1 The user accesses the URL of an HTML file that indicates that a Forms application should be run. 2 The HTML page is downloaded to the Web browser. 3 The Forms applet sends a request to the Forms Listener. 4 The Forms Listener contacts the Forms Runtime Engine and connects to a Forms Server run-time process. If included in the HTML file, Forms Runtime command-line parameters (such as form name, user ID and password, database SID, and so on) and any user-defined Form Builder parameters are passed to the process by the Forms Listener. 5 The Listener establishes a connection with the Runtime Engine and sends the connection information to the Forms applet. 6 The Forms applet then establishes a direct connection with the Runtime Engine. The Forms applet and Runtime Engine then communicate directly, freeing the Listener to accept startup requests from other users. 7 The Forms applet displays the application’s user interface in the main window of the user’s Web browser. Technical Note More information on Oracle Forms Server is covered in the course Oracle Forms Server: Deploy Internet Applications. Also, see Deploying Forms Applications to the Web with Oracle Forms Server Release 6i.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 2-7

Lesson 2: Running a Form Builder Application ......................................................................................................................................................

Client-Server Run-Time Components 2 3 1

4

Copyright  Oracle Corporation, 2000. All rights reserved.

1

MDI parent window

2

Default menu

3

Menu toolbar

4

Console

...................................................................................................................................................... 2-8 Oracle Forms Developer: Build Internet Applications I

Client-Server Environment: What You See at Run Time ......................................................................................................................................................

Client-Server Environment: What You See at Run Time Starting a Run-Time Session In a GUI environment, you usually start a Forms run-time session by selecting one of the following items: • An icon in the window system • A menu option in the window system In either case, this executes a run-time command to start a session. (The command name varies according to the platform). For example: IFRUN60 my_form scott/tiger

In a GUI environment, the Forms Run time Options screen is displayed when you execute the command (IFRUN60 in Microsoft Windows). Use this screen to enter the form name, the database user ID, and other options, if you did not specify them in the initial command. What Is the MDI Parent Window? The multiple-document interface (MDI) parent window is the container window in which your application can display multiple form modules (document windows). The title of the MDI parent window is Oracle Developer Forms Runtime. Note: The concept of MDI is only applicable to Microsoft Windows. What Is the SDI Window? Although MDI is the default system of window management during run time, Form Builder also provides support for a single-document interface (SDI) window on Microsoft Windows. What Is the Default Menu? The Default menu, which is part of all Oracle Forms Developer applications, is an alternative to keystroke operations. You can replace or customize the Default menu to introduce your own functionality into a form module.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 2-9

Lesson 2: Running a Form Builder Application ......................................................................................................................................................

Client-Server Run-Time Components 2 3 1

4

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Demonstration Launch the Forms Runtime component. Run the Orders form by using Orders.fmx. Point out the MDI parent window, Default menu, Menu toolbar, and Console components.

...................................................................................................................................................... 2-10 Oracle Forms Developer: Build Internet Applications I

Client-Server Environment: What You See at Run Time ......................................................................................................................................................

What Is the Menu Toolbar? The Menu toolbar contains buttons corresponding to menu items. At run time, it appears above any user-defined toolbars. It executes the same code as menu items, and it is a shortcut to menu commands that does not duplicate code or effort. What Is the Console? The console is the generic name for the standard features that provide information at run time. The console is displayed at the bottom of the window and consists of: • •

The message line that displays both Form Builder and applicationspecific messages. The status line that displays a variety of indicators to reflect the current state of the form module. Record: n/m

The nth record retrieved and displayed so far, out of m number of total records that can be retrieved by the query. Until the last record is viewed, m displays a “?”; after that it displays the number corresponding to the last record.

Enter-Query

The current block is in Enter Query mode and no records have been retrieved.

List of Values

A list of values (LOV) is associated with the current item.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 2-11

Lesson 2: Running a Form Builder Application ......................................................................................................................................................

Data Elements 1

2

3

8

4

9 5

7

6

Copyright  Oracle Corporation, 2000. All rights reserved.

1

Prompt

2

Text item

3

Button

4

Image item

5

Display item

6

Calculated field

7

Iconic button

8

Radio group

9

Check box

...................................................................................................................................................... 2-12 Oracle Forms Developer: Build Internet Applications I

Identifying the Data Elements ......................................................................................................................................................

Identifying the Data Elements Data elements in a Form Builder application are the same, regardless of whether the application is deployed on the Web or in a client-server environment: • Boilerplate text • Boilerplate graphics • Prompts • Text items • List items • Push buttons • Display items • Radio buttons • Check boxes • Image items • Sound items • Hierarchical Tree items • Chart items • Custom items The environment determines the appearance (layout and size of objects do not change) of the application and the data elements. The visually appealing characteristics that display when you run the application in a bitmapped environment are limited when you run it in a character mode environment.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 2-13

Lesson 2: Running a Form Builder Application ......................................................................................................................................................

Navigating at Run Time • • • • •

Default menu Menu toolbar Mouse Buttons Function keys

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Demonstration In the ORDERS form, point out the main data elements. Show the different means of navigation.

...................................................................................................................................................... 2-14 Oracle Forms Developer: Build Internet Applications I

Navigating a Form Builder Application ......................................................................................................................................................

Navigating a Form Builder Application The Default Menu The Default menu is automatically available in a form, unless it is disabled or replaced with a customized menu. Select options from the menu by using the mouse or function keys. At run time, use the menu to perform the following tasks: • Move the cursor and navigate between data blocks, records, and items. • Save or clear all changes. • Execute queries. • Insert new records or delete existing records. • Invoke Help. The Menu Toolbar You can use the Default menu toolbar buttons to perform the following operations also available through the Default menu: • Save all changes. • Exit the form. • Execute queries. • Navigate between data blocks or records. • Insert new records or delete existing records. • Invoke Help to see properties of an item. The Mouse You can use the mouse to navigate and to perform many user operations in a bitmapped environment without needing to learn the function keys. Use the mouse to perform the following actions: • Move the cursor. • Select from a menu. • Select from an LOV. • Select or clear a check box. • Select a button, including a radio group button. • Switch to an open window. • Respond to an alert. • Scroll records or lines by using a data block or item scroll bar. • Manipluate a custom item.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 2-15

Lesson 2: Running a Form Builder Application ......................................................................................................................................................

Navigating at Run Time • • • • •

Default menu Menu toolbar Mouse Buttons Function keys

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 2-16 Oracle Forms Developer: Build Internet Applications I

Navigating a Form Builder Application ......................................................................................................................................................

Buttons Web applications often use buttons as a means of navigation. You can click buttons with the mouse. Use buttons to perform the following tasks: • Move input focus. • Display a LOV. • Invoke an editor. • Invoke another window. • Commit data. • Issue a query. • Perform calculations. • Exit the form. Function Keys In addition to navigating with the mouse, you can move from item to item in sequence with function keys. Use function keys to perform the following tasks: • Navigate between data blocks, records, and items. • Execute queries. • Insert new records or delete existing ones. • Invoke Help. To view a list of keys and the functions they perform, select [Ctrl]+K.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 2-17

Lesson 2: Running a Form Builder Application ......................................................................................................................................................

Enter Query Mode

Allows:

Does not allow:



Unrestricted and restricted queries



Navigation out of current data block



Record count by using Query—>Count Hits

• • •

Exiting run-time session Certain functions Insert, update, delete

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 2-18 Oracle Forms Developer: Build Internet Applications I

Modes of Operation ......................................................................................................................................................

Modes of Operation Form Builder has two main modes of operation: Enter Query mode and Normal mode. Enter Query Mode Use Enter Query mode to enter search criteria for a database query. In Enter Query mode, your keystrokes are interpreted as search criteria for retrieving restricted data. What You Can Do in Enter Query Mode • Retrieve all records. • Retrieve records by using selection criteria. • Retrieve records by using the Query/Where dialog box. • Obtain the number of records that will be retrieved before fetching them from the database by using Query—>Count Hits. What You Cannot Do in Enter Query Mode • Navigate out of the current block. • Exit from the run-time session. • Use certain functions, such as Next Record. • Insert new records. • Update existing records. • Delete records.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 2-19

Lesson 2: Running a Form Builder Application ......................................................................................................................................................

Normal Mode

Allows:

Does Not Allow:

• • • •

Unrestricted queries

• •



Exiting run-time session

Insert, update, delete

Restricted queries Query/Where dialog box

Commit (Save) Navigation out of current data block

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 2-20 Oracle Forms Developer: Build Internet Applications I

Modes of Operation ......................................................................................................................................................

Normal Mode Use Normal mode to insert and alter records in the database. In Normal mode, your keystrokes are interpreted as either the entering of new records or the altering of existing ones. What You Can Do in Normal Mode • Retrieve all records. • Insert new records. • Update records. • Delete records. • Commit (Save) records. • Rollback (Clear) records. • Navigate outside of the current data block. • Exit the run-time session. What You Cannot Do in Normal Mode • Retrieve a restricted set of records. • Invoke the Query/Where dialog box.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 2-21

Lesson 2: Running a Form Builder Application ......................................................................................................................................................

Retrieving Data Unrestricted query A B 1 2 3 4

C

A B C D 1 2 3 4

D

Restricted query A B 3 4

C

D

A B C D 1 2 3 4

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 2-22 Oracle Forms Developer: Build Internet Applications I

Retrieving Data ......................................................................................................................................................

Retrieving Data You can use a form module to retrieve information from the database without knowing any SQL syntax. However, if you are an experienced SQL user, you may want to supplement Oracle Forms Developer default processing with your own SQL predicates. There are two general types of queries: Query Type

Description

Unrestricted (global query)

The equivalent of selecting all the rows for all the represented columns from the base table for the queried data block

Restricted

The equivalent of selecting a restricted set of rows for all the represented columns from the base table for the queried data block

Performing an Unrestricted Query You can retrieve unrestricted data by performing one of the following actions: • Select Query—>Execute. • Press the appropriate function key. • Click the Execute Query button. Note: You cannot perform a query while you have unsaved updates, inserts, or deletes. Either save or undo the changes before you continue with the query.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 2-23

Lesson 2: Running a Form Builder Application ......................................................................................................................................................

Retrieving Restricted Data •

Do not use quotation marks with character and date items.

• • • •

The LIKE operator is implied with % or _.



Use quotes around literals in Query/Where.

Use hash (#) in front of SQL operators. Use Query/Where for complex query conditions. Use default date format (DD-MON-YY) in Query/Where.

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note The default date format is dependent on the language/territory. In Oracle8i Release 2 (8.1.6), the default date formats were modified, replacing ’YY’ with ’RR’ and ’YYYY’ with ’RRRR’. For example, if NLS_LANG is set to Finland, then the default date format will be DD.MM.RRRR.

...................................................................................................................................................... 2-24 Oracle Forms Developer: Build Internet Applications I

Performing a Restricted Query ......................................................................................................................................................

Performing a Restricted Query You can perform a restricted query by using any one of the following methods: • Matching values • Matching patterns (wildcards) • A Query/Where dialog box for user entry of SQL predicates Valid Search Criteria Item

Criterion

Uses

Order ID

110

Exact match

Customer ID

%6

Implied LIKE operator

Order ID

#BETWEEN 105 AND 107

BETWEEN operator

Date Ordered

09/09/1992

Exact match by comparing the date, using the default format (09-SEP-92)

Payment Type

CASH

Exact match

Sales Rep ID

:S

Query Where dialog

How to Perform a Restricted Query 1 Do one of the following: - Select Query—>Enter. - Click the Enter Query button. - Press the appropriate function key. Enter-Query displays on the status line. 2 Enter search criteria into appropriate items. 3 Do one of the following: - Select Query—>Execute. - Click the Execute Query button. - Press the appropriate function key. Note: Form Builder constructs a select statement by using the AND operator for all specified conditions.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 2-25

Lesson 2: Running a Form Builder Application ......................................................................................................................................................

Query/Where Dialog Box •

Invoke by: – Entering :variable_name – Executing query



Used to write: – Complex search conditions – Queries with OR predicates – ORDER BY clause

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 2-26 Oracle Forms Developer: Build Internet Applications I

Using the Query/Where Dialog Box ......................................................................................................................................................

Using the Query/Where Dialog Box The Query Where dialog box is a window in which you enter complex search criteria by using raw SQL. Using the Query/Where dialog effectively requires knowledge of SQL. Use Query/Where to perform the following tasks: • Write complex search conditions. • Write queries with OR predicates. • Order the result of a query. Note: Form Builder logically uses the AND operator to append the Query/Where conditions to any other search criteria (including those imposed by the form designer) and constructs a SELECT statement. Example To restrict the query to orders with a Sales Rep ID (:S) of 11 OR an Order ID (:O) between 100 and 200, enter the following in the Query/Where dialog box: :S = 11 OR :O between 100 and 200

Example To sort the data by Sales rep ID (:S), enter the following in the Query/Where dialog box: ORDER BY :S

If you enter an ORDER BY at run time, it overrides any ordering defined by the designer.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 2-27

Lesson 2: Running a Form Builder Application ......................................................................................................................................................

Query/Where Dialog Box

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 2-28 Oracle Forms Developer: Build Internet Applications I

Using the Query/Where Dialog Box ......................................................................................................................................................

How to Use the Query/Where Dialog Box 1 Do one of the following: - Select Query—>Enter. - Click Enter Query. - Press the appropriate function key. 2 Enter a colon (:) followed by a unique character variable name in one or more items. 3 Do one of the following: - Select Query—>Execute. - Click Execute Query. - Press the appropriate function key. Note: Alternatively, you can select Query—>Count Hits if you simply want to know how many records will match your criteria. The Query/Where dialog box is displayed. 4 Enter the search criteria by using variables, SQL, and logical operators. 5 Click OK. Note: To perform a query without any variables, type only the colon (:) and execute the query. Doing so also displays the Query/Where dialog box.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 2-29

Lesson 2: Running a Form Builder Application ......................................................................................................................................................

Making Changes Permanent Memory Deletes Updates Form module

Inserts

FORMS RUNTIME Action

ORDERS Order

Save or

Item

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 2-30 Oracle Forms Developer: Build Internet Applications I

Inserting, Updating, and Deleting Records ......................................................................................................................................................

Inserting, Updating, and Deleting Records Upon entering a typical form module you are in Normal mode. This means that Form Builder regards anything you type into a blank record as an insert and anything you type over an existing record as an update. How to Insert a Record 1 Ensure that you have the cursor positioned on a blank record by taking one of the following actions: - Scroll down until you find one (always the last in the block). - Select Record—>Insert. - Click Insert Record (green +). - Press the appropriate function key. 2 Enter the data into the relevant items. How to Update a Record 1 Select Query—>Enter. 2 Enter the search criteria to retrieve the appropriate record. 3 Select Query—>Execute to retrieve all records that satisfy your specific search criteria. 4 Scroll through the records, stopping at the record to be updated. 5 Update the record. How to Delete a Record 1 Select Query—>Enter. 2 Enter the search criteria to retrieve the appropriate record. 3 Select Query—>Execute to retrieve all records that satisfy your specific search criteria. 4 Scroll through the records, stopping at the record to be deleted. Delete the record by taking one of the following actions: - Select Record—>Remove to clear the record and mark it for deletion. - Click Remove Record (red X) to clear the record and mark it for deletion. - Press the appropriate function keys.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 2-31

Lesson 2: Running a Form Builder Application ......................................................................................................................................................

Making Permanent Changes • •

Select Action—>Save to make changes permanent. Select Action—>Clear All to discard changes.

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 2-32 Oracle Forms Developer: Build Internet Applications I

Making Inserts, Updates, and Deletes Permanent ......................................................................................................................................................

Making Inserts, Updates, and Deletes Permanent To make any inserts, updates, or deletes permanent you must save (commit) them to the database. To do this, take one of the following actions: • Select Action—>Save. • Click Save in the menu toolbar. Discarding Inserts, Updates, and Deletes To discard any inserts, updates, or deletes, you must clear the records (rollback) instead of saving. Perform a rollback by selecting Action—>Clear All. Exiting a Run-Time Session In a GUI environment, you exit the run-time session by taking one of the following actions: • Select Action—>Exit. • Click Exit. • Press the appropriate function keys. Note: By default, you cannot exit the form while you have unsaved updates, inserts, or deletes. You need to either save or undo the changes before you can exit.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 2-33

Lesson 2: Running a Form Builder Application ......................................................................................................................................................

Display Error • • •

Use to view Oracle errors Select Help—>Display Error Shows: – SQL statement in error – Error information

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 2-34 Oracle Forms Developer: Build Internet Applications I

Displaying Errors ......................................................................................................................................................

Displaying Errors If an Oracle error is displayed on the message line while you are operating a form application, you can view the underlying SQL code by selecting Help—>Display Error. Example Here is the SQL statement in error and its corresponding error: SELECT deptno,dname,loc,ROWID FROM dept WHERE (deptno in (‘a’,’b’))

ORA-01722: invalid number Note: Selecting Help—>Display Error displays only those errors where the error on the message line is preceded by ORACLE error.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 2-35

Lesson 2: Running a Form Builder Application ......................................................................................................................................................

Summary •

The run-time environment for forms deployed on the Web



The run-time environment for forms deployed in a client-server environment

• • •

Data elements Navigation methods Modes of operation: – Normal mode – Enter Query mode

Copyright  Oracle Corporation, 2000. All rights reserved.

Summary •

Retrieving data: – Restricted queries – Unrestricted queries

• •

Inserting, updating, and deleting data Displaying errors

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 2-36 Oracle Forms Developer: Build Internet Applications I

Summary ......................................................................................................................................................

Summary This lesson introduced the operator interface of Form Builder. The following concepts were covered in this lesson: • The run-time environment for forms deployed on the Web • The run-time environment for forms deployed in a client server environment • The data elements of a form • Navigation methods • Modes of operation: - Normal mode - Enter Query mode • Retrieving data by performing: - Restricted queries—you supply search criteria - Unrestricted queries—you supply no search criteria • Inserting, updating, and deleting records • Displaying error information, when an error is reported by Form Builder Many other facilities are available when operating a form, depending on what the form designer has implemented. These other Form Builder facilities are discussed in the coming lessons.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 2-37

Lesson 2: Running a Form Builder Application ......................................................................................................................................................

Practice 2 Overview

This practice covers the following topics:



Running a form application on the Web and in a client-server environment

• •

Executing unrestricted and restricted queries



Saving changes to the database

Performing inserts, updates, and deletes in a form application

Copyright  Oracle Corporation, 2000. All rights reserved.

Note For solutions to this practice, see Practice 2 in Appendix A, “Practice Solutions.”

...................................................................................................................................................... 2-38 Oracle Forms Developer: Build Internet Applications I

Practice 2 Overview ......................................................................................................................................................

Practice 2 Overview In this practice session, you use the Summit application to query the database tables. You also insert, update, and delete data through the application. • Running a form application • Executing unrestricted queries to query database tables • Executing restricted queries and specify search criteria • Performing insert, update, and delete operations in a form application • Saving changes to the database

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 2-39

Lesson 2: Running a Form Builder Application ......................................................................................................................................................

Practice 2 Running a Forms Application on the Web 1 Run the form module Customers on the Web. Double-click the shortcut on your desktop for Run a Form on the Web. Enter the Runform parameters and run the Customers form. 2 Select Help—>Keys from the menu. 3 Execute an unrestricted query. 4 Execute a restricted query to retrieve information about the customer with the ID of 212. 5 Exit this run-time session. 6 Start another run-time session on the Web using the form module Customers. For this session, set the Runform parameter Look and Feel to Oracle. Notice the different appearance of the user interface. 7 Execute a restricted query to retrieve the “Womansport” record. Notice that the status line displays the words ENTER QUERY. Notice that only the one record is retrieved. 8 Execute a restricted query to retrieve customers with a Sales Rep ID greater than 13. 9 Try each of these restricted queries: - Retrieve all cities starting with San. - Retrieve all those customers based in the USA with a credit rating of Excellent. 10 Display the customer details for Big John’s Sports Emporium and click the Orders button to move to the Orders form module. 11 Click the Image Off button and notice that the image item no longer displays. Click the Image On button and notice that the image item displays. 12 Query only those orders with a payment type of Credit. 13 Move to the first record in the Item block and click the Stock button. The Inventory block displays in a separate window. Execute a query to get stock information. 14 Exit the run-time session.

...................................................................................................................................................... 2-40 Oracle Forms Developer: Build Internet Applications I

Practice 2 ......................................................................................................................................................

Running a Forms Session in Client-Server 1 Start a Forms Runtime session by using the form module Customers. 2 Select Help—>Keys from the menu. Notice that the function keys are defined differently in a client-server environment than they are for Web deployment. 3 For the customer Big John’s Sports Emporium, insert a new record in the ORDER block, as detailed below. Notice that some items are already populated with default values. Enter the following: Item Date Shipped Payment Type Order Filled

Value Today’s date (DD-MON-YYYY) Cash (Radio group button) No (Unchecked)

4 Insert a new record in the ITEM block.

Move to the ITEM block and enter the following: Item Product ID Quantity

Value 50530 2

5 Save the new records. 6 Update the order that you have just placed and save the change. 7 Attempt to delete the order that you have just placed. What happens? 8 Delete the line item for your order and save the change. 9 Now attempt to delete your order and save the change. 10 Exit the run-time session.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 2-41

Lesson 2: Running a Form Builder Application ......................................................................................................................................................

...................................................................................................................................................... 2-42 Oracle Forms Developer: Build Internet Applications I

3 ................................

Working in the Form Builder Environment

Lesson 3: Working in the Form Builder Environment ......................................................................................................................................................

Objectives

After completing this lesson, you should be able to do the following:

• • •

Identify the main Form Builder executables Identify the main components of Form Builder Identify the main objects in a form module

Copyright  Oracle Corporation, 2000. All rights reserved.

Schedule Topic Lecture Total

Timing 45 minutes 45 minutes

...................................................................................................................................................... 3-2 Oracle Forms Developer: Build Internet Applications I

Introduction ......................................................................................................................................................

Introduction Overview This lesson provides you with an overview of Form Builder, including a high-level description of its components and object hierarchy. Using this knowledge, you can plan and implement the structure of your form applications.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 3-3

Lesson 3: Working in the Form Builder Environment ......................................................................................................................................................

Form Builder Key Features

With Form Builder you can:

• •

Insert, update, delete, and query data



Control forms across several windows and database transactions

• • •

Access Graphics and OLE2 applications

Present data as text, sound, video, image, and ActiveX controls

Use integrated menus Send data to Oracle Reports Builder

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 3-4 Oracle Forms Developer: Build Internet Applications I

What Is Form Builder? ......................................................................................................................................................

What Is Form Builder? Form Builder is a major component of Oracle Forms Developer. It enables you to quickly develop form-based applications for presenting and manipulating data in a variety of ways. With Form Builder applications your users can: • Insert, update, delete, and query data by using a variety of interface items • Present data using text, sound, video, image, and custom controls, including JavaBeans and ActiveX • Control forms across several windows and database transactions • Access the facilities of Oracle Graphics Builder and OLE2 applications directly • Access comprehensive facilities by using integrated menus • Send data directly to Oracle Reports Builder As the designer of Form Builder applications, you can: • Design forms that use a number of data sources, including Oracle databases • Build applications quickly and easily by using powerful GUI development tools • Design applications for Internet deployment • Design applications that are portable across both GUI and character-mode environments • Copy and move objects and their properties easily between applications • Use design features such as wizards, the Layout Editor, Object Navigator, and PL/SQL Editor

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 3-5

Lesson 3: Working in the Form Builder Environment ......................................................................................................................................................

Form Builder Executables Form Builder

Forms Runtime

Form Compiler Definitions

Run files Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Explain the components of the product and their relationships.

...................................................................................................................................................... 3-6 Oracle Forms Developer: Build Internet Applications I

Form Builder Executables ......................................................................................................................................................

Form Builder Executables Form Builder includes three executables (components) that you can access as the designer of applications. Form Builder This is the application-building component of Oracle Forms Developer. This component lets you design and store the definitions of form, menu, and library documents. While in the Form Builder, you can invoke the other two components, Form Compiler and Forms Runtime. You must run the Form Builder component in a GUI environment in order to use its graphical design facilities. Form Compiler Once your form is built, use the Form Compiler. This reads the definition of your module and creates an executable run file. Forms Runtime This is the program that runs an executable form application, and the modules within it. The files used at run time must already have been compiled by the Form Compiler component. Invoking Form Builder Executables In a GUI environment, you usually store commands to invoke Form Builder components in menus and window icons for convenient access. You can also enter these commands on the command line. For example: IFRUN60 my_form scott/tiger

Note: Commands for invoking the product components vary according to platform.

Instructor Note If students want to know how to invoke other Forms Builder components from the command line, refer them to online Help. Enter Form Builder components as the search string and then select starting as the subtopic.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 3-7

Lesson 3: Working in the Form Builder Environment ......................................................................................................................................................

Form Builder Module Types

PL/SQL Library

Menus

Forms

Oracle Forms Developer components, Oracle Reports Developer

Libraries

Other Data sources

Object Library

ACTIVEX DDE OLE2

Database

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Explain the relationship among multiple forms, menus, and libraries.

...................................................................................................................................................... 3-8 Oracle Forms Developer: Build Internet Applications I

Form Builder Module Types ......................................................................................................................................................

Form Builder Module Types A Form Builder application can consist of many modules—that is, files. A module is a major component of your application and is the basis for storage and ownership. A module owns the rest of the objects in the system. A Form Builder module can be of the following types: • Form: As the main component of an application, the form module presents the objects and data that users can see or interact with. Data items in a form are arranged into records. • Menu: A menu module can consist of a hierarchy of menus, each with selectable items. • PL/SQL Library: A PL/SQL Library is a collection of PL/SQL program units whose code can be referenced and called from other modules. • Object Library: An Object Library is a collection of form objects that you can use in other modules. You can create it to store, maintain, and distribute standard objects that can be reused across the entire development organization. Form Builder provides the default menu for every form. The default menu includes commands for all basic database operations, such as insert, update, delete, query, and so on. If your application has specific requirements that are not met by the default menu, you can create a custom menu module. Menu modules are usually attached to form modules. In this way, the menus can provide a service to the facilities offered by a form, as well as options to invoke facilities elsewhere. PL/SQL Library documents can contain program units that can be used by other form and menu modules. You can build an application from multiple form modules, menu modules, and library documents as needed.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 3-9

Lesson 3: Working in the Form Builder Environment ......................................................................................................................................................

Blocks, Items, and Canvases Canvas 2

Canvas 1

Items Items Block A

Block B

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 3-10 Oracle Forms Developer: Build Internet Applications I

Form Builder Components ......................................................................................................................................................

Form Builder Components Form modules make up the main “body” of a Oracle Forms Developer application. They can consist of many object types, and some of these objects are visible to the user at run time. The three major objects in a form are: • Blocks: A block is the intermediate building unit for forms. Each form consists of one or more blocks. A block is the logical owner of items, rather like the sections of a paper form. Each item in a form belongs to a block. Items in one block are logically related; for example, they may correspond to columns in the same database table or may need to be part of the same navigation cycle. Blocks therefore provide a mechanism for grouping related items into a functional unit for storing, displaying, and manipulating records. • Items: These are interface objects that present data values to the user or enable the user to interact with the form, depending upon the item type. There are several different types of items. Items are logically grouped into blocks and visibly arranged on canvases. • Canvases: A canvas is a “surface” where visual objects, such as graphics and items, are arranged. A form module can have several canvases (like the pages of a paper form). A canvas can display items from one or more blocks. To see a canvas and its items, you must display the canvas in a window. By default, all canvases in a form appear in the same window (which could mean you see only one canvas at a time), but you can assign separate windows for each canvas so that several canvases can be viewed at once. Note: Items in one block do not need to be physically grouped. They can span many canvases (and windows). Instructor Note A canvas is like a picture portrait, and a window is like a picture frame. Just as you need a picture frame to display a picture portrait, you need a window to display a canvas and its contents.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 3-11

Lesson 3: Working in the Form Builder Environment ......................................................................................................................................................

Navigation in a Block

Canvas 1

Canvas 2

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 3-12 Oracle Forms Developer: Build Internet Applications I

Form Builder Components ......................................................................................................................................................

Navigation in a Form Module When you run a form, you principally navigate around its contents by way of items and blocks, not by canvases. Each item has a sequenced position within its block, and each block has a sequenced position in the form. When a user requests to move to the next item in a block, focus will be set on the next item in sequence, wherever that may be. If the next item is on a different canvas, Oracle Forms Developer displays that canvas automatically. Similarly, users can request to move to the next block (or previous block). If the first item in this block resides on another canvas, then that canvas is displayed automatically. Of course, if you can already see the item that you want to move to, then you may click on it directly with the mouse. You can also program mechanisms into the application to enable navigation in other ways.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 3-13

Lesson 3: Working in the Form Builder Environment ......................................................................................................................................................

Data Blocks A B C Master Data Block A

B

C

2

D

3

Table

4

1 X

Detail Data Block Y Z

5

X Y Z

6 Table Copyright  Oracle Corporation, 2000. All rights reserved.

1

Base table source

2

Single-record data block

3

Trigger access

4

Nonbase table source

5

Multirecord data block

6

Record

...................................................................................................................................................... 3-14 Oracle Forms Developer: Build Internet Applications I

Form Builder Components ......................................................................................................................................................

Types of Blocks In Form Builder there are two main types of blocks: data blocks and control blocks. Data Blocks When you build database applications with Form Builder, many of the blocks will be data blocks. A data block is associated with a specific database table (or view), a stored procedure, a FROM clause query, or transactional triggers. If it is based on a table (or view), the data block can be based on only one base table, even though the data block can be programmed to access data from more than one table and data sources. By default, the association between a data block and the database enables the user to automatically access and manipulate data in the database. However, to access data from other tables (nonbase tables), you need to write triggers. For a base table, Form Builder automatically performs the following actions: • Creates items in the data block to correspond to columns in the table (These items are data items or base table items.) • Produces code in the form to employ the rules of the table’s constraints • Generates SQL at run time (implicit SQL) to insert, update, delete, and query rows in the base table, based upon the user’s actions At run time, you can use standard function keys, buttons, menu options, or standard toolbar options to initiate query, insert, update, or delete operations on base tables, and the subsequent commit of the transaction. Control Blocks A control block is not associated with a database, and its items do not relate to any columns within any database table. Its items are called control items. For example, you can create many buttons in your module to initiate certain actions and to logically group these buttons in a control block.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 3-15

Lesson 3: Working in the Form Builder Environment ......................................................................................................................................................

Data Blocks A B C Master Data Block A

B

C

2

D

3

Table

4

1 X

Detail Data Block Y Z

5

X Y Z

6 Table Copyright  Oracle Corporation, 2000. All rights reserved.

1

Base table source

2

Single-record data block

3

Trigger access

4

Nonbase table source

5

Multirecord data block

6

Record

...................................................................................................................................................... 3-16 Oracle Forms Developer: Build Internet Applications I

Form Builder Components ......................................................................................................................................................

Master Versus Detail Blocks To support the relationship between data blocks and their underlying base tables, you can define one data block as the detail (child) of a master (parent) data block. This links primary key and foreign key values across data blocks, and synchronizes the data that these data blocks display. Form Builder automatically generates the objects and code needed to support masterdetail relationships. As the designer, you need only request it. Note: If your application requires it, you can also create independent data blocks in which there is no relationship between the two data blocks. Single-Record Versus Multirecord Blocks You can design a data block to show one record at a time (single-record block) or several records at once (multirecord block). Usually, you create a single-record data block to show master block data and a multirecord data block to show detail block data. In either case, records in a data block that are currently not visible on the screen are stored in a block buffer.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 3-17

Lesson 3: Working in the Form Builder Environment ......................................................................................................................................................

Forms and Data Blocks

Block 1

Block 1

Block 1

Form C Block 2

Open Form Block 2

Block 3

Open Form

Form A

Block 1 Form B

Multiple Form Modules

Block 4

Single Form Module Copyright  Oracle Corporation, 2000. All rights reserved.

Note This slide illustrates multiple data blocks in a single form compared to the multiple form application.

...................................................................................................................................................... 3-18 Oracle Forms Developer: Build Internet Applications I

Form Builder Components ......................................................................................................................................................

Many Blocks or Many Forms? Typically, a Form Builder application consists of more than one data block. With more than one data block, you can do the following: • Separate the navigation cycle of one group of items from another • Map each data block to a different database table (You can have one base table per data block.) • Produce a master-detail form, with a master data block and corresponding detail data blocks that are related to the master You can create a large form module with many data blocks. Alternatively, you can create several smaller form modules with fewer data blocks in each. Generally, a modular application with several smaller form modules has the following characteristics: • Modules are loaded only when their components are required, thus conserving memory. • Maintenance can occur on one module without regenerating or loading the others. • Forms can call upon one another, as required. • Parallel development can be carried out by different team members on different components. Here are some points to consider when grouping data blocks in the application: Data Blocks in the Same Form Module

Data Blocks in Different Form Modules

The data blocks can be directly linked in master-detail relationships.

The data blocks cannot be linked by the standard interblock relations.

Navigation between data blocks is handled by default functionality.

Navigation between data blocks of different forms is programmed by the designer (although mouse navigation to visible items can be automatic).

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 3-19

Lesson 3: Working in the Form Builder Environment ......................................................................................................................................................

Form Module Hierarchy Table

Database

Module Block(s) Blocks Column

Item Item

Trigger Trigger Program Program Units units

Frame Frame

Item Item

Canvas Canvas

Item Item Trigger Trigger Trigger Trigger

Window Window Copyright  Oracle Corporation, 2000. All rights reserved.

Technical Note A form module is made up of one or more blocks. A data block is based on a database object, such as a table or a view. A data block can contain both data items and control items. A frame can be created to arrange data block items. Each item in a block must appear on a canvas, and each canvas must appear in a window. A form module can have one or more canvases and windows. Using triggers, you can add functionality to your form. Triggers can be written at different levels in a form module. User-named program units enable you to write additional PL/SQL code through procedures, functions, and packages.

...................................................................................................................................................... 3-20 Oracle Forms Developer: Build Internet Applications I

Form Builder Components ......................................................................................................................................................

The Object Hierarchy You can create many types of objects in a form module. They are discussed in more detail in later lessons. In the following table, note that some objects are associated, even though one might not be “owned” by the other. Object

Description

Data block

Logical section of a form; owned by the form module

Item

Member of a data block (Items are functionally grouped into records.)

Canvas

The surface where visual objects are arranged; owned by the form module A canvas can contain text and graphics—static information that the user cannot interact with.

Window

Produced to contain the views of canvases; owned by the form module

Frame

A graphic object that appears on a canvas (A frame is used to arrange the items within a data block and is owned by the canvas it appears on.)

User-named program unit

Named procedure, function, or package; owned by the form module

Trigger

PL/SQL block executed on an event (Triggers can be owned by the form module, a data block, or an item, depending upon their scope.)

Other objects

Include alerts, parameters, and record groups (These are mainly owned by the form module itself.)

The structure of a menu module is discussed in the course Oracle Forms Developer: Build Internet Applications II. Instructor Note Point out the above objects to the students, using the Object Navigator.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 3-21

Lesson 3: Working in the Form Builder Environment ......................................................................................................................................................

Summary •

Form Builder allows screen-based querying, inserting, updating, and deleting of data.



Form Builder has powerful GUI and integration features.



Applications can consist of form modules, menu modules, and library documents.

Copyright  Oracle Corporation, 2000. All rights reserved.

Summary •

Form modules consist of logical data blocks, which are logical owners of items.



Items in a data block can span several canvases.

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 3-22 Oracle Forms Developer: Build Internet Applications I

Summary ......................................................................................................................................................

Summary •

• •

• •

With Form Builder, an Oracle Forms Developer component, you can develop form-based applications for presenting and manipulating data in a variety of ways. Form Builder enables screen-based queries, inserts, updates, and deletes of data. Form Builder provides powerful GUI and integration features. Applications consist of form modules, menu modules, and library documents. A form presents the objects and data with which users can see and interact. A menu module can consist of a hierarchy of menus, each with selectable items. A library document is a collection of PL/SQL program units. The use of the Object Library can ensure consistency and help prevent developers from re-creating objects that have already been developed. Form modules consist of logical data blocks. A data block is the logical owner of items. Items in one data block do not need to be physically grouped. Items in one data block can span several canvases.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 3-23

Lesson 3: Working in the Form Builder Environment ......................................................................................................................................................

...................................................................................................................................................... 3-24 Oracle Forms Developer: Build Internet Applications I

4 ................................

Creating a Basic Form Module

Lesson 4: Creating a Basic Form Module ......................................................................................................................................................

Objectives

After completing this lesson, you should be able to do the following:

• • •

Create a form module

• • • • •

Modify the layout by using the Layout Wizard

Create a data block Modify a data block by using the Data Block Wizard Save, compile, and run a form module Identify file formats and their characteristics Create data blocks with relationships Run a master-detail form module Copyright  Oracle Corporation, 2000. All rights reserved.

Schedule Topic Lecture Practice Session 1 Lecture Practice Session 2 Total

Timing 40 minutes 30 minutes 40 minutes 30 minutes 140 minutes

Instructor Note This lesson is divided into two sections. There is a practice midway through the lesson, and another practice at the end of the lesson.

...................................................................................................................................................... 4-2 Oracle Forms Developer: Build Internet Applications I

Introduction ......................................................................................................................................................

Introduction Overview Oracle Forms Developer applications usually consist of a number of form modules. Each form module consists of data blocks that are built using table specifications from the database. This lesson shows you how to create a basic form module and its data blocks.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 4-3

Lesson 4: Creating a Basic Form Module ......................................................................................................................................................

Creating a New Form Module Create an empty module Create data blocks and items Apply standards Fine-tune layout Set object properties Add code Test form module Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 4-4 Oracle Forms Developer: Build Internet Applications I

Creating a New Form Module ......................................................................................................................................................

Creating a New Form Module This lesson covers the basic process for creating a new form module and data blocks within it. How to Create a New Form Module 1 Create an empty form module. 2 Create data blocks and items. 3 Apply user interface standards to objects. 4 Fine-tune the layout. 5 Set object properties. 6 Add code. 7 Test the form module. Creating a New Form Module To Do This Create an empty module Create data blocks and items Apply standards Fine-tune the layout Set object properties Add code Test the form module

Use This Form Builder Tool Object Navigator Data Block Wizard Object Library Layout Wizard or Layout Editor Property Palette PL/SQL Editor Forms Runtime

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 4-5

Lesson 4: Creating a Basic Form Module ......................................................................................................................................................

Creating a New Form Module

Choose one of several methods:



Use wizards: – Data Block Wizard – Layout Wizard

• •

Build module manually Use template form

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Demonstration Create a new, empty form module and change its name.

...................................................................................................................................................... 4-6 Oracle Forms Developer: Build Internet Applications I

Creating a New Form Module ......................................................................................................................................................

Methods for Creating a New Form Module You can create a new form module in many different ways. • Invoke the Form Builder component. This takes you to the Form Builder Welcome page. Now do one of the following: - Select the “Use the Data Block Wizard” option, then follow the required data block creation steps. Then follow the Layout Wizard steps. - Select the “Build a new form manually” option. This takes you into the Form Builder Object Navigator (automatically creating an empty form module). - Select the “Build a form based on a template” option and use a template form. • If you are already in the Form Builder component, you can create a new form module by doing one of the following: - Double-click the Forms node in the Object Navigator (only when no other form modules are available). - Select File—>New—>Form. - Select the Object Navigator node for Forms, and then click the Create icon. Changing the Form Module Name • When you first build a form module, Form Builder assigns the name MODULEXX to the new form module, where XX is the next number available for module names. This name is displayed in the Object Navigator and in the Property Palette. You should change the default name to a meaningful name in either of the following places: • In the Object Navigator: - Double-click the form module name. - Change the default name as desired and press [Enter]. • In the Property Palette (shown on the next page) Note: Follow Oracle naming rules. Do not give two objects of the same type the same name. The name cannot include Oracle or Form Builder reserved words.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 4-7

Lesson 4: Creating a Basic Form Module ......................................................................................................................................................

Form Module Properties

Name property

Coordinate System property Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Open the Property Palette of the new form module. Concentrate only on the Name and Coordinate System properties. Point out that other properties will be discussed in later lessons. Open the Coordinate Info window and explain the implications of choosing the units. (72 points = 1 inch). Points allow for flexibility when designing cross platform applications.

...................................................................................................................................................... 4-8 Oracle Forms Developer: Build Internet Applications I

Creating a New Form Module ......................................................................................................................................................

Setting Form Module Properties Each form module consists of several objects. Objects within a form, and the form module itself, have properties that define their behavior. You can see the properties of an object and their values in its Property Palette. To open the Property Palette of an object, do one of the following: • Double-click the object’s icon in the Object Navigator. • Select the object in the Object Navigator and select Tools>Property Palette. Define the properties of the form module when you first create it. The properties affect the general behavior of the form and the objects within it. Properties for a form module include the following: Property Name Coordinate System

Description Specifies the internal name of the form module, as it appears in the Object Navigator Defines the units used to measure objects in the form and their positions (see next section)

Choosing a Unit for the Coordinate System When you click More in the Property Palette window with the Coordinate System property selected, the Coordinate Info window opens. The Coordinate System unit for a form can be one of the following: • Real - Unit can be pixel, centimeter, inch, point, or decipoint. - Real units are suitable for GUI applications and enable flexibility and fine alignment when adjusting object positions and sizes. • Character - Units are character cells (default size taken from the default font settings). - Character units are suitable where the run-time environment includes character mode devices. The default unit is point (Real). This means that object positions and sizes within the form are measured by this unit. Points provide fine alignment and consistency across different platforms and video devices.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 4-9

Lesson 4: Creating a Basic Form Module ......................................................................................................................................................

Creating a New Data Block

Use Form Builder Wizards:



Data Block Wizard: Create a data block with associated data source quickly and easily



Layout Wizard: Lay out data block contents for visual presentation



Create manually

Copyright  Oracle Corporation, 2000. All rights reserved.

Creating a New Data Block Launch Data Block Wizard

Reentrant mode

Enter data source

Launch Layout Reentrant mode Wizard New Data Block Lay out data block contents Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 4-10 Oracle Forms Developer: Build Internet Applications I

Creating a New Data Block ......................................................................................................................................................

Creating a New Data Block A form module consists of one or more data blocks and control blocks. Now that you know how to create a new form module, you need to create new data blocks within it. Block creation involves creating the data block and then laying out its contents for visual presentation. You can create a data block manually or by using the Form Builder wizards. In this lesson you learn how to create a new data block based on a database table, using the Data Block Wizard and the Layout Wizard. Note: Recall that a data block can be based on a table or view, a stored procedure, a FROM clause query, or a transactional trigger. In this course, you use database tables as the source; other sources for creating data blocks are covered in the course Oracle Forms Developer: Build Internet Applications II. Data Block Wizard The Data Block Wizard enables you to create (or modify) data blocks quickly and easily for use in your application. The wizard can automatically generate code to enforce integrity constraints in the database. Layout Wizard Although the Data Block Wizard allows you to create a new data block easily with its associated data sources, it does not deal with the visual presentation of objects included in the data block. Once you create the data block, you need to lay out its contents for user interaction. To accomplish this task quickly and easily, use the Layout Wizard. Note: The wizards are not the only way to perform a task such as building a data block, but they are usually the simplest. You can build a block manually instead of using the wizards.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 4-11

Lesson 4: Creating a Basic Form Module ......................................................................................................................................................

Navigating the Wizards

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note If you click the Next or Back buttons before entering all necessary information for a particular wizard page, the wizard prevents you from navigating to another page. Similarly, if you have not entered all necessary information into the wizard when you click Apply or Finish, the wizard automatically takes you to the page where you can finish entering the required information. The reason for showing a wizard page in reentrant mode is to illustrate all the buttons. The [Apply] button is only available in reentrant mode.

...................................................................................................................................................... 4-12 Oracle Forms Developer: Build Internet Applications I

Creating a New Data Block ......................................................................................................................................................

Navigating the Wizards The Data Block Wizard and the Layout Wizard provide several buttons to help you navigate: Button

Description

Cancel

Cancels any changes and exits the wizard

Help

Displays online help text for the current wizard page

Back

Navigates to the previous page in the wizard

Next

Navigates to the next page in the wizard

Apply

Applies your changes without exiting the wizard (available only upon reentering the wizard)

Finish

Saves any changes and exits the wizard

Note: Apply is available only when you reenter the Layout Wizard to modify an existing layout.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 4-13

Lesson 4: Creating a Basic Form Module ......................................................................................................................................................

Launching the Data Block Wizard In Form Builder, do one of the following:

• •

Select Tools—>Data Block Wizard. Click the right mouse button. Use the Data Block Wizard option.



Select the Data Blocks node and then click the Create icon in Object Navigator. Use the Data Block Wizard option.



Use the Data Block Wizard button on the toolbar in the Layout Editor

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Demonstration Create a new data block by using the Form Builder wizards. Base the data block on the S_ORD table.

...................................................................................................................................................... 4-14 Oracle Forms Developer: Build Internet Applications I

Creating a New Data Block ......................................................................................................................................................

Launching the Data Block Wizard Launch the Data Block Wizard by doing one of the following: • In Form Builder, do one of the following: - Select Tools—>Data Block Wizard from the Form Builder default menu system. - Click the right mouse button and select the Data Block Wizard option. - In the Object Navigator, select the Data Blocks node, then click the Create icon. In the New Data Block dialog box, select the Use the Data Block Wizard option. - In the Layout Editor, click the Data Block Wizard button on the toolbar. • If you are not already in Form Builder, launch Form Builder and select the Use the Data Block Wizard option in the Form Builder Welcome page.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 4-15

Lesson 4: Creating a Basic Form Module ......................................................................................................................................................

Data Block Wizard: Type Page

Copyright  Oracle Corporation, 2000. All rights reserved.

Data Block Wizard: Table Page

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note You can also select Oracle8 objects as object data sources in the Layout Wizard. Oracle8 objects as data sources are covered in the Build Internet Applications II course. Appendix E of this course describes the basics of Oracle8 objects.

...................................................................................................................................................... 4-16 Oracle Forms Developer: Build Internet Applications I

Creating a New Data Block ......................................................................................................................................................

Creating a New Data Block with the Data Block Wizard Use the Data Block Wizard to create a new data block with its associated data sources. The Data Block Wizard consists of several pages. To create a new data block, you must interact with each page. Type Page Choose between one of two data source types: • Table or View • Stored Procedure Select the Table or View (default) option. Table Page 1 Enter the table or view name for the data source name, or click Browse and select a name from a dialog box. 2 Click Refresh to display a list of columns in the selected table or view. If you are not connected to the database, the Connect box is displayed. 3 Select the columns you want to include in the data block. (Use [Control]click to select more than one column.) 4 Click >> or or < to include or exclude selected columns only. You can also drag and drop selected columns from one list to another. 5 Select the Enforce Data Integrity check box if you want the wizard to enforce the database integrity constraints. Note: If there is at least one other existing block in the current module, you next get the Master-Detail page, where you can associate the new data block with other master data blocks. This page is discussed later in the lesson. Finish Page Select the “Create the data block, then call the Layout Wizard” option. Select Finish to create the new data block and immediately invoke the Layout Wizard. Note: You have the option of exiting the Data Block Wizard at this stage, without immediately invoking the Layout Wizard. If you do so, you can either lay out the data block manually or invoke the Layout Wizard at a later time to lay out the items of a data block. To invoke the Layout Wizard at a later time, select the data block in the Object Navigator, and choose Tools—>Layout Wizard.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 4-17

Lesson 4: Creating a Basic Form Module ......................................................................................................................................................

Layout Wizard: Items Page

Copyright  Oracle Corporation, 2000. All rights reserved.

Layout Wizard: Style Page

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 4-18 Oracle Forms Developer: Build Internet Applications I

Creating a New Data Block ......................................................................................................................................................

Laying Out a New Data Block with the Layout Wizard Use the Layout Wizard to lay out the data block items for visual presentation quickly and easily. The Layout Wizard consists of several pages. You must interact with each page. Welcome Page

Click Next to continue.

Canvas Page 1 Select New Canvas from the Canvas pop-up list to get a new canvas on which to display the data block items. 2 Select Content as the canvas type in the Type pop-up list. Data Block Page 1 Select the items you want to display in the data block frame. (Use [Ctrl]-click to select more than one column.) 2 Click >> or or < to include or exclude selected items only. You can also drag and drop selected items from one list to another. Note: To lay out the items in a particular sequence, drag and drop items into that sequence. 3 You can use the Item Type pop-up list to select a type for each item. The default type is Text for each item. Note: An item type can also be changed later to something else, such as pop-up list or radio group. Items Page Specify the prompt text and the display width and height for each display item for the data block. Style Page Select a layout style for your frame. Your options are: • Form (usually used to create single-record data blocks) • Tabular (usually used to create multirecord data blocks)

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 4-19

Lesson 4: Creating a Basic Form Module ......................................................................................................................................................

Layout Wizard: Rows Page

Copyright  Oracle Corporation, 2000. All rights reserved.

Data Block Functionality

Once you create a data block with the wizards, Form Builder automatically creates:



A form module with database functionality including query, insert, update, delete

• • •

A frame object Items in the data block A prompt for each item

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 4-20 Oracle Forms Developer: Build Internet Applications I

Creating a New Data Block ......................................................................................................................................................

Laying Out a New Data Block with the Layout Wizard (continued) Rows Page 1 Enter a title in the Frame Title field. 2 Enter the number of records you want to display at run time in the Records Displayed field. 3 Enter the physical distance (in the coordinate system unit of the form) between records. 4 You can select the Display Scrollbar check box to display a scroll bar next to the frame (common for multirecord data blocks). Finish Page Select Finish to create a new frame and lay out the selected items for the new data block. The Layout Wizard steps are complete. Note: Once you complete the Layout Wizard steps, you can view the layout in the Layout Editor. Here you can customize or modify the layout if necessary. Data Block Functionality Once you create a new data block by using the wizards, Form Builder automatically creates the following objects for you: • A new form module with a default menu (Basic database functionality such as querying, inserting, updating, and deleting is automatically available on the items in the base table block when you run the new form.) The new data block is created with default property values. These values can be modified to change the behavior of the form. • A frame object to arrange the items within the new data block • An item for each database table column included in the data block (Each item is assigned default property values to match the underlying column specifications.) • A prompt for each item in the data block (The default prompt is the name of the column.)

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 4-21

Lesson 4: Creating a Basic Form Module ......................................................................................................................................................

Modifying the Layout •





Reentrant Layout Wizard: – Select frame in Object Navigator. – Select Tools—>Layout Wizard. or – Select frame in Layout Editor. – Click Layout Wizard button. Layout Editor: – Select Tools—>Layout Editor. – Make changes manually. Frame Property Palette: Change property values. Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Demonstration Invoke the Layout Wizard in reentrant mode to show how to modify the layout of the new data block created in the previous demonstration. Make sure you select the correct frame before invoking the Layout Wizard.

...................................................................................................................................................... 4-22 Oracle Forms Developer: Build Internet Applications I

Modifying the Layout ......................................................................................................................................................

Modifying the Layout Once you create a data block, you may want to customize or modify its layout. You can do this by doing one of the following: • Reenter the Layout Wizard (see the next section), and use it to make the changes. • Select Tools—>Layout Editor to invoke the Layout Editor and make changes manually in the editor. • Change the property values of the frame in its Property Palette. Invoking the Layout Wizard in Reentrant Mode A very powerful feature of the Layout Wizard is its ability to operate in reentrant mode. Use the reentrant mode to modify the layout of items in an existing frame, even if the frame was not originally created with the Layout Wizard. Invoke the Layout Wizard in reentrant mode from the Object Navigator or the Layout Editor. • From the Object Navigator: - Select the appropriate frame (under the Canvases node). - Select Tools—>Layout Wizard. or Click the right mouse button and select the Layout Wizard option. • In the Layout Editor: - Select the appropriate frame. - Click Layout Wizard. Note: Before you reenter the Layout Wizard, it is important to select the correct frame in the Object Navigator or the Layout Editor. If you overlook this when you reenter the Layout Wizard, you may create an additional frame instead of modifying the current frame. Either method takes you to the Data Block page in the Layout Wizard. Use the Next and Back buttons as before, or go directly to a certain page by clicking the particular page tab. Note: If necessary, you can also invoke the Data Block Wizard in reentrant mode to modify an existing data block. To do so, select the existing data block in the Object Navigator, and choose Tools—>Data Block Wizard.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 4-23

Lesson 4: Creating a Basic Form Module ......................................................................................................................................................

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 4-24 Oracle Forms Developer: Build Internet Applications I

Template Forms ......................................................................................................................................................

Template Forms You can create a new form based on standard template forms, so that you can provide other team members with a default starting point. Templates typically include generic objects, such as graphics, toolbars, and program units. You can define standard window layouts, standard toolbars, and other common objects that you want to include in new forms. Creating a Form Based on a Template To create a form based on a template, follow these steps: 1 Start Form Builder. 2 In the Welcome to the Form Builder dialog box, select the “Build a form based on a template” option, and then click OK.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 4-25

Lesson 4: Creating a Basic Form Module ......................................................................................................................................................

Saving a Form Module •

Save the form module: – Select File—>Save. – Click the Save icon.

• •

Enter a filename. Save to one of the following: – File system – Database

Copyright  Oracle Corporation, 2000. All rights reserved.

Compiling a Form Module •

Compile explicitly: – Select File—>Administration—>Compile File. – Launch the Form Compiler component. – Initiate from Command line interface.



Compile implicitly: – Select Tools—>Preferences. – Set the Build Before Running preference.

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note The file system icons for FMB and FMX files have changed in Release 6i. Note that the icon for FMX files has a red dot in the lower right corner.

...................................................................................................................................................... 4-26 Oracle Forms Developer: Build Internet Applications I

Saving, Compiling, and Running a Form Module ......................................................................................................................................................

Saving, Compiling, and Running a Form Module Saving a Form Module You can save the form module definition by doing one of the following: • Select File—>Save. • Select the Save icon. Both of these options display the File dialog box for the initial save. In the dialog box, do the following: 1 Enter a filename. 2 Click OK. Note: You can choose to save a form module to either the database or the file system by setting your preference after selecting Tools—>Preferences. If you save to the file system, an .fmb file is produced. This saved definition of a form in the file system or database is not executable. Note: When you work with more than one module at a time, Form Builder keeps track of the changes you make to each module separately. When you issue a Save command, only the current module is saved. Compiling a Form Module Before you can run a form, you must compile an executable (.fmx) file from the design (.fmb) file you created in Form Builder. Compiling a form (or menu) module creates the needed executable file. • You can compile a form explicitly by doing one of the following: - Selecting File—>Administration—>Compile File after opening the form module - Launching the Form Compiler component - Initiating the process from the command line interface • You can compile a form implicitly or automatically by checking the Build Before Running preference. Form Builder implicitly compiles the form module when you attempt to run it. Set this preference by selecting Tools—>Preferences. Note: Compiling and saving are two independent tasks. Performing one does not automatically accomplish the other. Both tasks must occur separately.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 4-27

Lesson 4: Creating a Basic Form Module ......................................................................................................................................................

Running a Form Module • • • •

Web browser Forms Runtime component Command line interface Form Builder component – Select Program—>Run Form and then select the desired option. – Click one of the Run icons.

Copyright  Oracle Corporation, 2000. All rights reserved.

Running a Form Module on the Web •

Create an HTML file.





View the URL in a browser.

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note The Run Form Web button requires that Oracle Forms Server be installed on the client machine. That is not the recommended setup for this class.

...................................................................................................................................................... 4-28 Oracle Forms Developer: Build Internet Applications I

Saving, Compiling, and Running a Form Module ......................................................................................................................................................

Running a Form Module You can run a form module from one of the following: • Web browser • Forms Runtime component • Command line interface • Form Builder component - Select Program—>Run Form and then one of the three Run Form options: Run Form Option

Description

Run Form Client/Server

Use this option to run your form by using the client-server architecture.

Run Form Web

Use this option to run your form in the Web Previewer. Your form will look and behave as though being deployed from a Web server. The Web Previewer can be used to test your Web forms without having to actually deploy the forms on a server.

Run Form Debug

Use this option to invoke the debug mode for the Forms Runtime session.

or - Click one of the three Run icons. Note: If more than one form module is open in Form Builder, make the form module you want to run the current one by selecting any of its objects in the Object Navigator. Running a Form Module on the Web Once a standard Web server and Oracle Forms Server have been installed and configured, Forms applications can be run from a browser by using an HTML file. The HTML file specifies the Forms Server to connect to, the module name, the username, and other application-specific parameters. A sample HTML file is provided with Oracle Forms Server to use as a starting point for your own application. To run the application, simply open your browser and specify the appropriate URL. Note: Configuring a Web browser and Forms Server and creating an HTML file are covered in detail in the course Oracle Forms Server: Deploy Internet Applications.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 4-29

Lesson 4: Creating a Basic Form Module ......................................................................................................................................................

Text Files and Documentation • •

Convert a binary file to a text file. Create an ASCII file for a form module.

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 4-30 Oracle Forms Developer: Build Internet Applications I

Saving, Compiling, and Running a Form Module ......................................................................................................................................................

Producing Text Files and Documentation The files normally produced by saving and generating modules are in binary format. You can convert a binary file to text by doing the following: 1 Select File—>Administration—>Convert. This opens the Convert dialog box. 2 Select the type of module (Form, Menu, PL/SQL Libraries, Object Libraries), the file to convert, and the direction (Binary-to-Text). 3 Select Convert. This produces a text file for the module. You can produce documentation for your module by doing the following: 1 Select the module to be documented in the Object Navigator. 2 Select File—>Administration—>Object List Report from the menu system. This produces an ASCII file with the name .txt.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 4-31

Lesson 4: Creating a Basic Form Module ......................................................................................................................................................

Module Types

Form Module

.fmb

.fmx

.fmt

Menu Module

.mmb

.mmx

.mmt

PL/SQL Library

.pll

.plx

.pld

Object Library

.olb

.olt

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 4-32 Oracle Forms Developer: Build Internet Applications I

Saving, Compiling, and Running a Form Module ......................................................................................................................................................

Module Type and Storage Format When you create form modules, menu modules, and library documents in Form Builder they are stored in source files that have a binary format and are portable across platforms. The application files that your users run are also in a binary format; however, they are not portable across platforms. Module/ Document

Extension

Storage Format

Portable

Form

.fmb

Form module binary

Yes

.fmx

Form module executable; executable

No

.fmt

Form module text

Yes

.mmb

Menu module binary

Yes

.mmx

Menu module executable; executable

No

.mmt

Menu module text

Yes

.pll

PL/SQL Library document binary

Yes

.plx

PL/SQL Library document executable (no source)

No

.pld

PL/SQL Library document text

Yes

.olb

Object Library module binary

Yes

.olt

Object Library module text

Yes

Menu

PL/SQL Library

Object Library

Note: .pll is portable but requires recompilation, because it contains both source and compiled pcode.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 4-33

Lesson 4: Creating a Basic Form Module ......................................................................................................................................................

Practice 4-1 Overview

This practice covers the following topics:

• •

Creating a new form module



Saving and running the form module

Creating a data block by using Form Builder wizards

Copyright  Oracle Corporation, 2000. All rights reserved.

Note For solutions to this practice, see Practice 4-1, in Appendix A, “Practice Solutions.” Instructor Note Advise the students not to spend too much time trying to get the layout of the CUSTOMER block to exactly match the screenshot provided in Appendix A, because the layout for the items in this block will be modified in a later lesson.

...................................................................................................................................................... 4-34 Oracle Forms Developer: Build Internet Applications I

Practice 4-1 Overview ......................................................................................................................................................

Practice 4-1 Overview The practice session for this lesson is divided into Part 1 and Part 2. In Part 1, you will create one new form module. You will create a single-block form that displays a single record. • Create a new form module called CUSTOMERS. Create a new data block in this form by using the Form Builder wizards, and base it on the S_CUSTOMER table. Using the Layout Editor, reposition the items in this block to match the screenshot provided. • Save and run the new form module on the Web.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 4-35

Lesson 4: Creating a Basic Form Module ......................................................................................................................................................

Form Block Relationships

Master

Master

Detail

Detail

Master

Detail

Detail

Detail

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 4-36 Oracle Forms Developer: Build Internet Applications I

Creating Data Blocks with Relationships ......................................................................................................................................................

Creating Data Blocks with Relationships A form module can contain one or more data blocks. Each data block can stand alone or be related to another data block. Master-Detail Relationship A master-detail relationship is an association between two data blocks that reflects a primary-foreign key relationship between the database tables on which the two data blocks are based. The master data block is based on the table with the primary key, and the detail data block is based on the table with the foreign key. A master-detail relationship equates to the one-to-many relationship in the entity relationship diagram. A Detail Block Can Be a Master You can create block relationships in which the detail of one master-detail link is the master for another link. A Master Block Can Have More Details You can create more than one detail block for a master block. Note: The following are examples of the master-detail structure: • Master-detail: Order-items • Master-detail-detail: Customer-order-items • Master-2*detail: Customer-order and customer-shipping contacts Instructor Note The Data Block Wizard also enables you to select an Oracle8 object when creating relationships.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 4-37

Lesson 4: Creating a Basic Form Module ......................................................................................................................................................

Data Block Wizard: Master-Detail Page

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Demonstration Create a second data block, using the Form Builder wizards. Base the block on the S_ITEM table. In the Data Block Wizard, create a master-detail relationship between the new data block and the S_ORD data block.

...................................................................................................................................................... 4-38 Oracle Forms Developer: Build Internet Applications I

Creating Data Blocks with Relationships ......................................................................................................................................................

Creating a Master-Detail Form Module with the Data Block Wizard You can build a master-detail form module either by creating a relation between a master and detail block explicitly, or by using the Data Block Wizard. 1 Create the master block as described earlier in this lesson. 2 Invoke the Data Block Wizard in the Object Navigator. 3 Follow the same steps as before to create a new data block in the Data Block Wizard until you come to the Master-Detail page. On this page, select the “Auto-join data blocks” check box and click Create Relationship. Note: If the “Auto-join data blocks” check box is clear, the Data Block dialog is displayed with a list of all data blocks in the form without any foreign key constraint names. 4 Select a master data block in the Data Block dialog and click OK. The wizard automatically creates the join condition between the detail and master data blocks in the Join Condition field and displays the name of the master data block in the Master Data Blocks field. Note: If the “Auto-join data blocks” check box is clear, the wizard does not automatically create the join condition between the detail and master data blocks. You must use the Detail Item and Master Item pop-up lists to create a join condition manually. 5 Click Next and finish the Data Block Wizard steps. Go through the Layout Wizard steps as described earlier in this lesson to finish creating and laying out the detail data block. Note: The master data block must exist in the form module before you create the detail block. You can also create a relation by invoking the Data Block Wizard in reentrant mode.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 4-39

Lesson 4: Creating a Basic Form Module ......................................................................................................................................................

Relation Object •

New relation object created in Object Navigator under master data block node



Default name assigned: MasterDataBlock_DetailDataBlock



Triggers and program units generated automatically

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 4-40 Oracle Forms Developer: Build Internet Applications I

Creating Data Blocks with Relationships ......................................................................................................................................................

New Relation Once you create a master-detail form module, the Data Block Wizard automatically creates a form object that handles the relationship between two associated data blocks. This object is called a relation. The following tasks occur automatically: • The new relation object is created under the master data block node in the Object Navigator with default properties. • The relation is given the following default name: MasterDataBlock_DetailDataBlock, for example S_ORD_S_ITEM • Triggers and program units are generated to maintain coordination between the two data blocks.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 4-41

Lesson 4: Creating a Basic Form Module ......................................................................................................................................................

Creating a Relation Manually

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 4-42 Oracle Forms Developer: Build Internet Applications I

Creating a Relation Manually ......................................................................................................................................................

Creating a Relation Manually 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 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 by setting the properties in the New Relation dialog box. Like implicitly created relations, PL/SQL program units and triggers are created automatically when you explicitly create a relation. How to Create a Relation Explicitly 1 Select the master block entry in the Object Navigator. 2 Click the Create icon. The New Relation window is displayed. 3 Specify the name of the detail block. 4 Choose your master delete property. 5 Choose your coordination property. 6 Specify the join condition. 7 Click OK. The new relation, new triggers, and new program units are highlighted in the Object Navigator.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 4-43

Lesson 4: Creating a Basic Form Module ......................................................................................................................................................

Deletion Properties = Deleted

Isolated

Cascading

Nonisolated No Detail Rec Master-Detail Records Nonisolated Detail Rec

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 4-44 Oracle Forms Developer: Build Internet Applications I

Modifying a Relation ......................................................................................................................................................

Modifying a Relation You can alter the relation properties to affect the way deletes and block coordination are handled. Master Deletes You can prevent, propagate, or isolate deletion of a record in a master block when corresponding records exist in the detail block by setting the Delete Record Behavior property. For example, you can delete all corresponding line items when an order is deleted. Property

Use

Non-Isolated

Prevents the deletion of the master record when the detail records exist

Cascading

Deletes the detail records when a master record is deleted

Isolated

Deletes only the master record

Note: Although deleting with the cascading property may remove many detail records, the commit message shows only the number of records deleted from the master block. What Happens When You Modify a Relation? • Changing the Delete Record Behavior property from the default of NonIsolated to Cascading replaces the On-Check-Delete-Master trigger with the Pre-Delete trigger. • Changing the Delete Record Behavior property from the default of NonIsolated to Isolated results in the removal of the On-Check-DeleteMaster trigger.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 4-45

Lesson 4: Creating a Basic Form Module ......................................................................................................................................................

Coordination Properties

Default

Deferred with auto query

Deferred without auto query

Copyright  Oracle Corporation, 2000. All rights reserved.

Join Condition • •

Creates primary-foreign key link between blocks Define using: – Block and item names – SQL equijoin syntax

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Demonstration Explicitly add a relation between the Department and Employee blocks of explrela.fmb. Set the deletion property to Cascading and the coordination property to Deferred with Auto-Query.

...................................................................................................................................................... 4-46 Oracle Forms Developer: Build Internet Applications I

Modifying a Relation ......................................................................................................................................................

Coordination You can control how the detail records are displayed when a master block is queried by setting the coordination property. For example, you can defer querying the line items for an order until the operator navigates to the item block. Coordination Property

Use

Default

Forces coordination of blocks to occur whenever the master record is changed by a user or a trigger

Deferred with Auto Query

Postpones potentially expensive detail query processing until the cursor visits the related blocks

Deferred Without Auto Query

Allows entry of additional query criteria in the detail block prior to querying

Prevent Masterless Operations

Ensures that the detail block cannot be queried or used to insert records when a master record is not displayed

Note: Setting the Deferred property to Yes enables the Auto Query check box. Join Condition Use to: • Create links between blocks using SQL • Alter links between blocks using SQL Define using: • Usual SQL equi-join condition syntax • Block names instead of the base table names • Item names that exist in the form module instead of base table column names

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 4-47

Lesson 4: Creating a Basic Form Module ......................................................................................................................................................

Running a Master-Detail Form Module •

Automatic block linking for: – Querying – Inserting



Default deletion rules: Cannot delete master record if detail records exist

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 4-48 Oracle Forms Developer: Build Internet Applications I

Running a Master-Detail Form Module ......................................................................................................................................................

Running a Master-Detail Form Module When you run your master-detail form module you will find that: • Querying the master data block immediately retrieves corresponding detail records. • Deleting a master record is prevented if detail records exist. Note: You can change the above behavior by modifying the relation object properties. • Inserting a detail record automatically associates it with the currently displayed master.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 4-49

Lesson 4: Creating a Basic Form Module ......................................................................................................................................................

Summary •

Build a new form module: – Using Form Builder wizards – Manually – Using a template form

• •

Use the Data Block Wizard—data source. Use the Layout Wizard—visual presentation.

Copyright  Oracle Corporation, 2000. All rights reserved.

Summary • • • •

Modify layout—reentrant wizards. Save, compile, and run a form module. Use module types and storage formats. Create master-detail form module.

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 4-50 Oracle Forms Developer: Build Internet Applications I

Summary ......................................................................................................................................................

Summary •

• • •

• •



Building a new form module by using the following methods: - Form Builder wizards - Manually - Template form Using the Data Block Wizard to create a new data block with its associated data sources quickly and easily Using the Layout Wizard to quickly lay out the new data block contents for user interaction Modifying the data block layout: - Using reentrant wizards - Changing frame properties Saving the form module to preserve its definition; compiling it to get an executable file; running the form module to test it Using several module types and storage formats that are available for form modules, menu modules, PL/SQL Library documents, and Object Library modules Creating data blocks with a master-detail relationship

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 4-51

Lesson 4: Creating a Basic Form Module ......................................................................................................................................................

Practice 4-2 Overview

This practice covers the following topics:

• •

Creating a master-detail form module



Saving and running the form module

Modifying data block layout by using the Layout Wizard in reentrant mode

Copyright  Oracle Corporation, 2000. All rights reserved.

Note For solutions to this practice, see Practice 4-2, in Appendix A, “Practice Solutions.”

...................................................................................................................................................... 4-52 Oracle Forms Developer: Build Internet Applications I

Practice 4-2 Overview ......................................................................................................................................................

Practice 4-2 Overview In Part 2, you will create a new form module that displays master-detail information. • Create a master-detail form module called ORDERS. Create a master block based on the S_ORD table and a detail block based on the S_ITEM table. Create a third data block that is not related to any other block in the form module. Base this block on the S_INVENTORY table, and manually create a relation with the block based on the item table. Use the Form Builder wizards to create all three data blocks. • Invoke the Layout Wizard in reentrant mode, and change the layout of the S_ITEM and S_INVENTORY data blocks. • Save and run the new form module on the Web.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 4-53

Lesson 4: Creating a Basic Form Module ......................................................................................................................................................

Practice 4-1 1 Create a new form module.

Create a new single block by using the Data Block Wizard. Base it on the S_CUSTOMER table and include all columns. Display the S_CUSTOMER block with a form style layout on a new content canvas called CV_CUSTOMER and show just one record at a time. Set the frame title to Customers. Hint: Manually rename the canvas in the Object Navigator. 2 Save the new module to a file called CUSTGXX, where XX is the group number that your instructor has assigned to you. Run your form module and execute a query. Navigate through the fields. Exit run time and return to Form Builder. 3 Change the form module name in the Object Navigator to CUSTOMERS. 4 In the Layout Editor, reposition the items, so that the canvas resembles the screenshot below. Hint: First resize the canvas and the frame.

5 Save and compile the form module.

Deploy your form module on the Web and execute a query.

...................................................................................................................................................... 4-54 Oracle Forms Developer: Build Internet Applications I

Practice 4-2 ......................................................................................................................................................

Practice 4-2 1 Create a new form module.

2

3 4

5

Create a new block by using the Data Block Wizard. Base it on the S_ORD table and include all columns except TOTAL. Display the S_ORD block on a new content canvas called CV_ORDER and show just one record at a time. Use a form style layout. Set the frame title to Orders. Hint: Manually rename the canvas in the Object Navigator. Create a new block by using the Data Block Wizard. Base the block on the S_ITEM table and include all columns. Create a relationship and select the master block as S_ORD. Display all items except ORD_ID on the CV_ORDER canvas. Display six records in this detail block on the same canvas as the master block. Use a tabular style layout and include a scroll bar. Change the order of the blocks in the Object Navigator, moving the S_ITEM block after the S_ORD block. Set the frame title to Items. Save the new module to a file called ORDGXX, where XX is the group number that your instructor has assigned to you. Create a new block based on S_INVENTORY (do not create any relationships with other blocks at this time) to display on a different canvas. Base it on the S_INVENTORY table; exclude the OUT_OF_STOCK_EXPLANATION column from the definition. Display four records in this block and ensure that they display on a new content canvas called CV_INVENTORY. Use a tabular style layout, and include a scroll bar. In the Object Navigator move the S_INVENTORY block after the S_ITEM block. Set the frame title to Stock. Do not create any relationships between blocks at this time. Create a relation called S_Item_S_Inventory explicitly between the S_Item and S_Inventory blocks. Ensure that line item records can be deleted independently of any related inventory. Set the coordination so that the Inventory block is not queried until you explicitly execute a query.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 4-55

Lesson 4: Creating a Basic Form Module ......................................................................................................................................................

6 On the S_ITEM block change the prompt for the Quantity Shipped item

to Shipped by using the reentrant Layout Wizard. First select the relevant frame in the Layout editor, then use Layout Wizard. 7 In the S_INVENTORY data block, change the prompt for Amount in Stock to In Stock by using the Layout Wizard. 8 Save and compile your form module. Run your form module on the Web. Execute a query. Navigate through the blocks so that you see the S_INVENTORY block. Exit run time, close Netscape Communicator, and return to Form Builder. 9 Change the form module name in the Object Navigator to ORDERS and save.

...................................................................................................................................................... 4-56 Oracle Forms Developer: Build Internet Applications I

5 ................................

Working with Data Blocks and Frames

Lesson 5: Working with Data Blocks and Frames ......................................................................................................................................................

Objectives

After completing this lesson, you should be able to do the following:

• • •

Identify the components of the Property Palette Manipulate properties through the Property Palette Control the behavior and appearance of data blocks

Copyright  Oracle Corporation, 2000. All rights reserved.

Objectives • •

Control frame properties



Delete data blocks and their components

Create blocks that do not directly correspond to the database

Copyright  Oracle Corporation, 2000. All rights reserved.

Schedule Topic Lecture Practice Total

Timing 60 minutes 40 minutes 100 minutes

...................................................................................................................................................... 5-2 Oracle Forms Developer: Build Internet Applications I

Introduction ......................................................................................................................................................

Introduction Overview In this lesson you will learn how to customize existing data blocks and modify frames. You will also learn how to include blocks that are not associated with the database.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 5-3

Lesson 5: Working with Data Blocks and Frames ......................................................................................................................................................

Modifying the Appearance and Behavior of Data Blocks • • • •

Reentrant wizards Layout Editor Data Block Property Palette Frame Property Palette

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 5-4 Oracle Forms Developer: Build Internet Applications I

Managing Object Properties ......................................................................................................................................................

Managing Object Properties Modifying the Appearance and Behavior of Data Blocks You can modify the appearance and behavior of a data block after it has been created. To do this use one of the following methods: • Reentrant wizards: Reenter the Data Block Wizard or the Layout Wizard as described in the previous lesson to modify the data source and visual presentation of objects within the data block. • Layout Editor: Invoke the Layout Editor and make your modifications manually. • Data Block Property Palette: Open the Data Block Property Palette and change individual property values to modify the behavior of the data block at run time. • Frame Property Palette: Open the associated Frame Property Palette and change individual property values to modify the arrangement of items within the data block.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 5-5

Lesson 5: Working with Data Blocks and Frames ......................................................................................................................................................

Displaying the Property Palette

Use one of several methods:

• •

Select Tools—>Property Palette.

• •

Double-click the object in Layout Editor.

Double-click the object icon in the Object Navigator. Click the right mouse button.

Copyright  Oracle Corporation, 2000. All rights reserved.

Property Palette Features Find field

Toolbar Expand/ Collapse

Search Backward Search Forward

Property name

Property value

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 5-6 Oracle Forms Developer: Build Internet Applications I

Managing Object Properties ......................................................................................................................................................

Property Palette Every object in a form module, as well as the form module itself, has properties that dictate the object’s behavior. When an object is first created, it is automatically assigned several property values by default. You can change these property values in the Property Palette. Displaying the Property Palette To display the Property Palette of an object, use any of the following methods: • Select the object in the Object Navigator and then select Tools—>Property Palette from the menu system. • Double-click the object icon for the object in the Object Navigator (except for code objects and canvases). • Double-click an item in the Layout Editor. • Select the object in the editor or the Object Navigator, and then click the right mouse button. From the pop-up menu, select the Property Palette option. Property Palette Features Feature

Description

Property list

The property list displays a two-column list of property names and property values. Properties are grouped under functional headings or nodes. You can expand or collapse a node by using the plus and minus icons beside the node name.

Find field

The Find field enables you to quickly locate the name of a particular property. The Search Forward and Search Backward buttons enhance your search.

Toolbar

The toolbar consists of a series of buttons that provide quick access to commands.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 5-7

Lesson 5: Working with Data Blocks and Frames ......................................................................................................................................................

Property Controls • • • •

Text field Pop-up list LOV window More button

Copyright  Oracle Corporation, 2000. All rights reserved.

Note Once you activate the Property Palette for an object, its window remains open. The window automatically displays the properties of each object you visit in the Layout Editor or Object Navigator. This is because, by default, the list of properties in the Property Palette is synchronized whenever you select an object. You can turn the synchronization on or off for a specific palette by clicking Freeze/ Unfreeze in that Property Palette toolbar.

...................................................................................................................................................... 5-8 Oracle Forms Developer: Build Internet Applications I

Managing Object Properties ......................................................................................................................................................

Using the Property Palette Each form object has various types of properties. Properties are manipulated differently, depending on the property type. Here is a summary of controls used in the Property Palette: Property Control

Description

Text field

This is displayed when the current property can be set by entering a text value. For longer text values, an iconic button also appears, enabling you to open a text editor.

Poplist

This occurs where the property is Yes or No, or where a fixed set of values are allowed. Click the down arrow to open the list and select a value. Alternatively, double-click the property name to cycle through the values.

LOV window

LOVs occur where a potentially large list of possible values is available. Click the iconic button in the property value column to invoke an LOV.

More button

Use this when more complex settings are needed. Click the More button to open the extra dialog.

Property Palette Icons Each property in a Property Palette has an icon to its left. Here is a summary of these icons and their description: Icon

Description

Circle

Specifies that the property value is the default value

Square

Specifies that the property value has been changed from the default

Arrow

Specifies that the property value is inherited

Arrow with a cross

Specifies that the property value was inherited but has been overridden

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 5-9

Lesson 5: Working with Data Blocks and Frames ......................................................................................................................................................

Visual Attributes •

Visual attributes: – Are font, color, and pattern properties – Can be set for form and menu objects



A visual attribute is a form object with font, color, and pattern properties.



Set the Visual Attribute Group property to the visual attribute object.

Copyright  Oracle Corporation, 2000. All rights reserved.

Font, Pattern, and Color Picker

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Demonstration Create a visual attribute to be used later in this lesson. Use the Color, Pattern, and Font pickers. Use the ordwk04.fmb file.

...................................................................................................................................................... 5-10 Oracle Forms Developer: Build Internet Applications I

Managing Object Properties ......................................................................................................................................................

Visual Attributes Visual attributes are the font, color, and pattern properties that you set for form and menu objects. A visual attribute is another object that you can create in the Object Navigator with properties such as font, color, and pattern combinations. When creating visual attributes, you can use the Font Picker and Color Picker to select the font and color. When changing a font from the Property Palette, click the Font group itself to invoke the Font Picker. Every interface object in a forms application has a property called Visual Attribute Group, which determines how the individual visual attribute settings of an object are derived. The Visual Attribute Group property can be set to Default, NULL, or the name of a named visual attribute object. Partial Visual Attributes Partial visual attributes are just like visual attributes, except that you need to set only the properties that you want to be inherited by the objects that use them. This means that you can apply a visual attribute that changes the font color without having to set the font name.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 5-11

Lesson 5: Working with Data Blocks and Frames ......................................................................................................................................................

Data Block Properties

Copyright  Oracle Corporation, 2000. All rights reserved.

Data Block Property Groups • • • • • • • • •

General Navigation Records Database Advanced Database Scrollbar Font and Color Character Mode International

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 5-12 Oracle Forms Developer: Build Internet Applications I

Managing Object Properties ......................................................................................................................................................

Data Block Properties Each data block has several properties. These properties are divided into the following groups: • General • Navigation • Records • Database • Advanced Database • Scrollbar • Font and Color • Character Mode • International Instructor Note The properties of several objects have been renamed from previous versions. To get a detailed listing of the renamed properties, refer to the “Renamed properties” topic in the online documentation. In the Help Topics: Form Builder Help window, select the Contents tab, and expand the relevant topics until you get to the “Renamed properties” topic.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 5-13

Lesson 5: Working with Data Blocks and Frames ......................................................................................................................................................

Navigation Properties ORDERS Order

Previous Navigation Data Block Same Record Next Record

Item

Next Navigation Data Block Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Demonstration Use the ordwk04.fmb file to show the run-time effect of changing the Navigation Style property on the S_ITEM block.

...................................................................................................................................................... 5-14 Oracle Forms Developer: Build Internet Applications I

Controlling the Behavior of Data Blocks ......................................................................................................................................................

Controlling the Behavior of Data Blocks Setting Navigation Properties Navigation Style Normally, when you navigate beyond the last item in a record, Form Builder returns you to the beginning of the same record. With this property you can change the location of the cursor. The following settings are valid for the Navigation Style property: • Same Record (default) • Change Record • Change Data Block Note: If you want the cursor to move to the next record when you reach the end of the current record, set the Navigation Style property for the block to Change Record. Previous/Next Navigation Data Block Each data block in a form module has a sequenced position in the data block object hierarchy. Normally, when you perform an operation to move to the previous or next data block at run time, Form Builder moves control to the previous or next adjacent data block in sequence. These properties enable you to name the previous or next data block to which to navigate from the current one. .

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 5-15

Lesson 5: Working with Data Blocks and Frames ......................................................................................................................................................

Database Properties

Use properties in the Database group to control:

• •

Type of block—data or control block

• • • •

Data block’s data source

Query, insert, update, and delete operations on the data block Query search criteria and default sort order Maximum query time Maximum number of records fetched

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 5-16 Oracle Forms Developer: Build Internet Applications I

Controlling the Behavior of Data Blocks ......................................................................................................................................................

Setting Database Properties Database Data Block This property is set to Yes if the data block is based on a database object and No if it is a control block. Enforce Primary Key This controls whether Form Builder checks that records are unique before they are inserted or updated in the base table, in order to avoid committing duplicate rows in the database. A value of Yes means that the form checks that inserted or updated records in the client-side record group are unique before an attempt is made to commit possible duplicate rows. Query/Insert/Update/Delete Allowed These properties control whether the associated operations can be performed on the data block records. Query Data Source Type This property specifies the type of the query data source for the data block. Possible values for this property are None, Table, Procedure, Transactional Triggers, or FROM clause query. Query Data Source Name This property specifies the name of the query data source for the data block. This property is used only if the type of the query data source is Table, FROM clause query, or Procedure. Query Data Source Columns This property specifies, in a dialog box, the name and data type of the columns associated with the query data source. This property is used only if the type of the query data source is Table, FROM clause query, or Procedure. WHERE Clause This property specifies a SQL condition that is attached to every default SELECT statement associated with the data block through implicit SQL. This clause is automatically appended (ANDed) with any conditions supplied by the operator in Enter Query mode. Use this property to define general restrictions on the rows this data block may fetch.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 5-17

Lesson 5: Working with Data Blocks and Frames ......................................................................................................................................................

Database Properties

Records Records buffered fetched

Block display SELECT .... WHERE Clause [ORDER BY Clause]

Work file

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note When Update Changed Columns Only is set to No, Form Builder can reuse the same SQL statement for multiple updates without having to reparse each time in the system global area (SGA). Changing this property value to Yes can degrade performance because the update statement must be reparsed each time.

...................................................................................................................................................... 5-18 Oracle Forms Developer: Build Internet Applications I

Controlling the Behavior of Data Blocks ......................................................................................................................................................

Setting Database Properties (continued) ORDER BY Clause This clause defines a default order for records displayed from a query. The operator can alter this order by using the Query Where dialog box at run time. Optimizer Hint This property specifies a hint string that Form Builder passes to the Optimizer when constructing implicit SQL on the data block. Using the Optimizer can improve the performance of database transactions. Locking Mode/Key Mode These properties control how Form Builder handles records and transactions when the data block is primarily associated with non-Oracle data sources. The default settings are usually appropriate for data blocks connected with an Oracle database. Update Changed Columns Only When this property is set to Yes, only those items updated by the operator are written to their corresponding database columns. If the operator commonly updates or inserts records with only one or two columns, this can save network traffic. By default, this property value is set to No, so that all columns are included in the default UPDATE statement. Enforce Column Security When this property is set to Yes, items in the data block can be updated only if the current user has permission to update the corresponding database columns. Maximum Query Time This property provides the option to abort a query when the elapsed time of the query exceeds the value of this property. This property is useful when the Query All Records property is set to Yes. Maximum Records Fetched This property provides the option to abort a query when the number of records fetched exceeds the value of this property. This property is useful when the Query All Records property is set to Yes.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 5-19

Lesson 5: Working with Data Blocks and Frames ......................................................................................................................................................

Records Properties Vertical Record Orientation

Horizontal Record Orientation

Copyright  Oracle Corporation, 2000. All rights reserved.

Records Properties

Item

Current Record

Number of Records Displayed

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 5-20 Oracle Forms Developer: Build Internet Applications I

Controlling the Appearance of Data Blocks ......................................................................................................................................................

Controlling the Appearance of Data Blocks Setting Record Properties Current Record Visual Attribute Group This group names a visual attribute that will be used to highlight the current record in the data block. Query Array Size This size specifies the maximum number of records that Form Builder should fetch from the database at one time. A lower value in this property value means faster response time; however, a larger value means fewer calls to the database for records, thereby resulting in reduced overall processing time. Number of Records Buffered This is the minimum amount of buffer space retained for holding queried records in the data block. The minimum setting allowed is the value of the Number of Records Displayed property plus 3. Form Builder buffers any additional records to a temporary disk file. Number of Records Displayed This property specifies the maximum number of records the data block can display on the canvas at one time and how many records you can see at once. If you change this value, make sure there is enough room on the canvas layout for the number of records, or objects may overlap. Query All Records This property specifies whether all the records matching the query criteria should be fetched when a query is executed. (This query is necessary to support the Calculated Field feature.) Record Orientation This property determines the orientation of records in the data block—horizontal or vertical. When you set this property, Form Builder adjusts the display position of items in the data block accordingly. Single Record This property specifies that the control block should always contain one record. Set this property to Yes for a control block that contains a summary calculated item. Note: You cannot set this property to Yes for a data block.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 5-21

Lesson 5: Working with Data Blocks and Frames ......................................................................................................................................................

Scroll Bar Properties

Item

Scroll Bar X/Y Position

Scroll Bar Height

Scroll Bar Width

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Improve processing speed by increasing the number of records buffered. Save memory by decreasing the number of records buffered. This can, however, result in slower disk I/O. Demonstration This demonstration is for the previous page. Using the ordwk04.fmb, assign the visual attribute created earlier to the S_ITEM block. Show the run time effect of doing this. Also show how to increase or decrease the number of records displayed in a data block.

...................................................................................................................................................... 5-22 Oracle Forms Developer: Build Internet Applications I

Controlling the Appearance of Data Blocks ......................................................................................................................................................

Setting Scroll Bar Properties • Show Scroll Bar: This property specifies whether Form Builder should create a scroll bar for the data block. To delete an existing scroll bar, set this property to No. • Scroll Bar Canvas: This property specifies the canvas on which the data block scroll bar will be displayed. The specified canvas must exist in the form. • Scroll Bar Tab Page: This property specifies the canvas tab page on which the scroll bar will be displayed. • Scroll Bar Orientation: This property specifies whether the scroll bar should be displayed horizontally or vertically. • Scroll Bar X/Y Position: This property specifies the x and y coordinates (measured in the coordination system units of the form) where the scroll bar will display on the canvas. The default value for both coordinates is 0. • Scroll Bar Width/Height: This property specifies the width and height of the scroll bar. • Reverse Direction: This property specifies that the scroll bar scrolls in reverse. Setting this value to Yes causes Form Builder to fetch the next set of records when the user scrolls upward. If the user scrolls downward, Form Builder displays already fetched records.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 5-23

Lesson 5: Working with Data Blocks and Frames ......................................................................................................................................................

Frame Properties ORDERS Order Form Layout Style

Item Tabular Layout Style Distance between records

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Stress the importance of the Update Layout property.

...................................................................................................................................................... 5-24 Oracle Forms Developer: Build Internet Applications I

Controlling Frame Properties ......................................................................................................................................................

Controlling Frame Properties The selections that you make in the Layout Wizard when creating a data block are recorded as properties of the resulting layout frame object. You can change frame properties to modify the arrangements of items within a data block. The main frame properties are as follows: Layout Data Block This property specifies the name of the data block with which the frame is associated. The items within this data block are arranged within the frame. Note: A data block can be associated with only one frame. You cannot arrange a block item within multiple frames. • Update Layout: Specifies when the frame layout is updated. Valid settings are: - Automatically: The layout is updated whenever you move or resize the frame, or modify any frame layout property. - Manually: The layout is updated whenever you use the Layout Wizard to modify the frame, or in the Layout Editor, when you click Update Layout or select the Arrange—>Update Layout menu option. - Locked: The layout is locked and cannot be updated. • Layout Style: This property specifies the layout style for the items within the frame. Choose between Form and Tabular styles. • Distance Between Records: This property specifies the physical distance (measured in the form’s coordination system units) with which to separate records displayed in the frame. • X/Y Position: This property specifies the x and y coordinates (measured in the form’s coordination system units) of the frame’s position on the canvas. • Width/Height: This property specifies the width and height of the frame (measured in the form’s coordination system units). Note: You can arrange a frame as well as the objects within it manually in the Layout Editor.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 5-25

Lesson 5: Working with Data Blocks and Frames ......................................................................................................................................................

Multiple Property Palettes •

Display multiple Property Palettes for an object: 1 Open a Property Palette for the object. 2 Hold down the [Shift] key and double-click the object icon for an additional palette.



Display Property Palettes for multiple objects: 1 Open the Property Palette for first object. 2 Click the Freeze/Unfreeze button on the toolbar. 3 Invoke Property Palette for the next object.

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 5-26 Oracle Forms Developer: Build Internet Applications I

More About Object Properties ......................................................................................................................................................

More About Object Properties Displaying Multiple Property Palettes • To display the properties of an object in multiple Property Palettes: While one Property Palette is already open, hold down the [Shift] key and double-click the object icon for the object in the Object Navigator. • To display the Property Palettes for multiple objects at the same time: 1 Open the Property Palette of the first object. Click Freeze/Unfreeze on the toolbar to “freeze” this palette. 2 Invoke the Property Palette for another object. This Property Palette appears in a separate window. If the second window is on top of the first one, drag it alongside the first window.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 5-27

Lesson 5: Working with Data Blocks and Frames ......................................................................................................................................................

Setting Properties on Multiple Objects

Intersection/ Union

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Show how to select multiple objects in the Object Navigator, and how their combined properties can be represented in the Property Palette. Switch between Intersection and Union, pointing out the difference between the properties.

...................................................................................................................................................... 5-28 Oracle Forms Developer: Build Internet Applications I

More About Object Properties ......................................................................................................................................................

Setting Properties on Multiple Objects You can view and set the properties of several objects simultaneously, whether they are the same or different object types. To do this, select the objects in the Object Navigator and display a combination of the properties in the Property Palette. The combination or set may be: • Intersection (∩): A subset in which you display only the common properties of the selected objects (This is the default set operator.) • Union (∪): A superset in which you display both the common properties and the unique properties of the selected objects Where there are differing values for a property across the selected objects, you will see ***** in the property value. This changes to a definitive value once you enter a new value in the Property Palette. This new value then applies to each of the selected objects to which the property is relevant. How to Set Properties on Multiple Objects 1 Open the Property Palette for one of the objects. 2 Hold down the [Ctrl] key and click each object in the Object Navigator or the editors whose properties are to be viewed or changed in combination. The selected objects are highlighted. 3 Set the Intersection/Union button from the toolbar in the Property Palette to the desired operation. This button toggles between the two options. 4 Change the displayed properties, as required. Your changes are applied to all selected objects with these properties. Note: With a union, some properties you see might not be relevant to all of the selected objects. Changes to a property are applied only to objects that have the property.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 5-29

Lesson 5: Working with Data Blocks and Frames ......................................................................................................................................................

Copying Properties Copy

Paste

Name Query All Records Query Allowed Insert Allowed Update Allowed Delete Allowed

Source objects

No Query All Records Yes Query Allowed Yes Properties Insert Allowed Yes Update Allowed Yes Delete Allowed

S_ITEM Yes Yes Yes No Yes

Destination objects

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Show how to copy the properties of one object to another. Do not save the effects of this demonstration. Note: Property inheritance and variance are covered in a later lesson.

...................................................................................................................................................... 5-30 Oracle Forms Developer: Build Internet Applications I

More About Object Properties ......................................................................................................................................................

How to Copy Properties to Other Objects You can write the properties and values from the Property Palette to a buffer, so that they can be applied (pasted) to other objects in your design session. 1 In the Property Palette, display and set the properties to be copied. This may be from one object or a combination of them. - To copy all the property settings from the Property Palette, select Edit—>Select All. - To copy selected property settings only, hold down the [Ctrl] key and click each property individually. 2 Click Copy Properties on the toolbar of the Property Palette. 3 From the Object Navigator select the object into which the properties are to be copied. 4 In the Property Palette, click Paste Properties. The selected object receives values from all copied properties that are relevant to their object types. Note: It is possible to copy the property settings of an object to objects of different types. In this case, properties that do not apply to the target object are ignored. Property Classes When you display a list of properties (from either one object or a combination of objects) in the Property Palette, the list of property names and associated values can be saved for future application to other objects. This is known as a property class, which is a Form Builder object in its own right. Objects can inherit some of their properties from a linked property class, so their properties will automatically change if the associated properties are changed in the property class. Property classes are discussed in more detail in a later lesson.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 5-31

Lesson 5: Working with Data Blocks and Frames ......................................................................................................................................................

Creating a Control Block •

Click the Data Blocks node and click the Create icon. or Select Navigator—>Create.



Select the “Build a new data block manually” option in the New Data Block dialog box.

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Demonstration Create a control block in the form module, using the ordwk04.fmb file.

...................................................................................................................................................... 5-32 Oracle Forms Developer: Build Internet Applications I

Creating Control Blocks ......................................................................................................................................................

Creating Control Blocks A control block is a block that is not associated with any database, and its items do not relate to any columns within any database table. This means that Form Builder does not perform an automatic query when the operator issues an Enter Query or Execute Query command, nor does it issue an automatic Insert, Update, or Delete for the block when the operator saves changes to the database. How to Create a Control Block 1 Click the Data Blocks node in the Object Navigator. 2 Click the Create icon on the toolbar. or Select Navigator—>Create from the menu. 3 In the New Data Block dialog box, select the “Build a new data block manually” option. 4 Open the Property Palette of the new data block and change its name. Note: Because there are no database columns on which to base control block items, a control block has no items until you manually add them later.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 5-33

Lesson 5: Working with Data Blocks and Frames ......................................................................................................................................................

Deleting a Data Block •

Select a data block for deletion and click the Delete icon. or Select Navigator—>Delete.



Click Yes in the alert box.

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Demonstration Delete the S_ITEM data block in the ordwk04.fmb file. Show the effect of doing this in the Layout Editor. Do not save the effects of this demonstration.

...................................................................................................................................................... 5-34 Oracle Forms Developer: Build Internet Applications I

Deleting Data Blocks ......................................................................................................................................................

Deleting Data Blocks To delete a data block: 1 Select the data block to be deleted in the Object Navigator. 2 Click the Delete icon on the toolbar. or Select Navigator—>Delete from the menu. 3 An alert is displayed for delete confirmation. Click Yes to delete the data block. Note: Deleting a data block also deletes its subordinate objects (items and triggers). If the data block was a master or detail block in a relation, the relation is also deleted. However, the frame border and its title will remain. Delete the frame manually in the Layout Editor.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 5-35

Lesson 5: Working with Data Blocks and Frames ......................................................................................................................................................

Summary •

Modify the data block properties in its Property Palette to change its behavior.



Data blocks have Navigation, Database, Records, Scrollbar, and other properties.



Database properties include WHERE Clause, Query Data Source, and Maximum Records Fetched.



Change frame properties to modify the arrangements of items within a data block.

Copyright  Oracle Corporation, 2000. All rights reserved.

Summary •

A control block is not associated with the database.



Copy properties between data blocks and other objects.



View and change properties of several objects together (Intersection/Union).

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 5-36 Oracle Forms Developer: Build Internet Applications I

Summary ......................................................................................................................................................

Summary • • • • • •

Modify the data block properties in its Property Palette to change its behavior at run time. Data blocks have Navigation, Database, Records, Scrollbar, and other properties. Database properties include WHERE Clause, Query Data Source Type, and Maximum Records Fetched. You can change frame properties to modify the arrangements of items within a data block. You can copy properties between data blocks and other objects. You can view and change the properties of several objects together. You can use Intersection or Union settings to connect their properties in the Property Palette.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 5-37

Lesson 5: Working with Data Blocks and Frames ......................................................................................................................................................

Practice 5 Overview

This practice covers the following topics:

• • • •

Creating a control block Creating a visual attribute Modifying data block properties Modifying frame properties

Copyright  Oracle Corporation, 2000. All rights reserved.

Note For solutions to this practice, see Practice 5 in Appendix A, “Practice Solutions.”

...................................................................................................................................................... 5-38 Oracle Forms Developer: Build Internet Applications I

Practice 5 Overview ......................................................................................................................................................

Practice 5 Overview In this practice session, you will create control blocks and modify several data block properties as well as frame properties. • Create a control block in the CUSTOMERS form. • Using the Property Palette, change properties in the S_CUSTOMER data block to change its run-time appearance and behavior. Change the related frame properties to change the run-time appearance and to keep any layout changes you make manually in the Layout Editor. Save and run the form after the changes are applied. • Create a control block in the ORDERS form. • Create a visual attribute in the ORDERS form and use it to highlight the current record in the S_ITEM and S_INVENTORY data blocks at run time. Use the multiple selection feature on both data blocks when setting the appropriate property in the Property Palette. • Change properties in the S_ITEM and S_INVENTORY data blocks to change their run-time appearance and behavior. Change the frame properties of all the data blocks in the ORDERS form to change their run-time appearance and to keep any layout changes you make manually in the Layout Editor. Save and run the form after the changes are applied.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 5-39

Lesson 5: Working with Data Blocks and Frames ......................................................................................................................................................

Practice 5 CUSTGXX Form 1 Create a control block in the CUSTGXX form. Create a new block manually, and rename this block CONTROL. Set the Database Data Block, Query Allowed, Insert Allowed, Update Allowed, and Delete Allowed Database properties to No. Set the Query Data Source Type property to None. Leave other properties as default. Move the CONTROL block after the S_CUSTOMER block. 2 Ensure that the records retrieved in the S_CUSTOMER block are sorted by the customer’s ID. 3 Set the frame properties for the S_CUSTOMER block as follows: Remove the frame title, and set the Update Layout property to Manually. 4 Save and run the CUSTGXX form. Test the effects of the properties that you have set. Note: The Compilation Errors window displays a warning that advises you that the CONTROL block has no items. This is expected (until you add some items to the CONTROL block in a later lesson). ORDGXX Form 5 Create a control block in the ORDGXX form. Create a new block manually, and rename this block CONTROL. Set the Database Data Block, Query Allowed, Insert Allowed, Update Allowed, and Delete Allowed database properties to No. Set the Query Data Source Type property to None. Leave other properties as default. Position the CONTROL block after the S_INVENTORY block in the Object Navigator. Hint: You can copy the CONTROL block from the CUSTGXX form.

...................................................................................................................................................... 5-40 Oracle Forms Developer: Build Internet Applications I

Practice 5 ......................................................................................................................................................

ORDGXX Form (continued) 6 Ensure that the current record is displayed differently from the others in both the S_ITEM and S_INVENTORY blocks. Create a visual attribute called Current_Record. Using the Color Picker, set the Foreground Color to White and the Background Color to Dark Cyan. (If these colors are not available on your window manager, use other colors instead.) Using the Pattern Picker, choose any fill pattern. Using the Font Picker, set the font to MS Serif italic 10 point. (If that font is not available on your window manager, use any available font.) Use the multiple selection feature on both data blocks to set the relevant block property to use this visual attribute. 7 For the S_ITEM block, change the number of records displayed to 4 and resize the scroll bar accordingly. 8 Ensure that the records retrieved in the S_ITEM block are sorted by the ITEM_ID. 9 Set the property that causes automatic navigation to Next Record, when the user uses [Next Item] to exit the last item of a record in the S_ITEM block. 10 Set the frame properties for all blocks as follows: Remove the frame title and set the Update Layout property to Manually. 11 Save and compile the ORDGXX form. Deploy your form on the Web. Test the effects of the properties that you have set.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 5-41

Lesson 5: Working with Data Blocks and Frames ......................................................................................................................................................

...................................................................................................................................................... 5-42 Oracle Forms Developer: Build Internet Applications I

6 ................................

Working with Text Items

Lesson 6: Working with Text Items ......................................................................................................................................................

Objectives

After completing this lesson, you should be able to do the following :

• • • •

Describe text items Create a text item Modify the appearance of a text item Control the data in a text item

Copyright  Oracle Corporation, 2000. All rights reserved.

Objectives • •

Modify the navigational behavior of a text item

• •

Modify the functionality of a text item

Enhance the relationship between the text item and the database Include Help messages

Copyright  Oracle Corporation, 2000. All rights reserved.

Schedule Topic Lecture Practice Total

Timing 60 minutes 40 minutes 100 minutes

...................................................................................................................................................... 6-2 Oracle Forms Developer: Build Internet Applications I

Introduction ......................................................................................................................................................

Introduction Overview The default item type in an Oracle Forms Developer application is the text item or field. You have seen how creating a new data block based on a table creates text items for each selected column from that table. This lesson shows you how to customize text items to change their appearance and behavior.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 6-3

Lesson 6: Working with Text Items ......................................................................................................................................................

Text Items • •

Default item type Interface object for: – Querying – Inserting – Updating – Deleting



Behavior defined in the Property Palette

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note • Although the technical term item is used in design terminology, end users see these objects as fields. • Ensure that the class does not get confused between item as a Form Builder term for the objects in a block, and item as the application term for line item records in the Order Entry system.

...................................................................................................................................................... 6-4 Oracle Forms Developer: Build Internet Applications I

What Is a Text Item? ......................................................................................................................................................

What Is a Text Item? A text item is an interface object through which you can query, insert, update, and delete data. A text item usually corresponds to a column in the database table. When an item is first created, its default type is text. The item type determines the properties available in the Property Palette. In this lesson you look at the properties of a text item. Remaining item types are covered in subsequent lessons. Use the Property Palette to define, alter, or examine the characteristics of items.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 6-5

Lesson 6: Working with Text Items ......................................................................................................................................................

Creating a Text Item Canvas selection

Block selection

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Demonstration • In the first demonstration, show how to create a text item in the Layout Editor. • In the second demonstration, create a text item in the Object Navigator and do the following: - Go to the Layout Editor. The new text item is not seen. Point out to the students that this is a Null canvas item, because it is not assigned to any canvas yet. - Open the text item property sheet, and assign the Canvas property to the desired canvas. - Show the text item in the Layout Editor. • Point out the importance of creating a new text item in the correct data block and canvas. Also point out the Canvas and Block pop-up lists in the Layout Editor.

...................................................................................................................................................... 6-6 Oracle Forms Developer: Build Internet Applications I

Creating a Text Item ......................................................................................................................................................

Creating a Text Item You can create a text item by doing one of the following: • Converting an existing item into a text item • Using the Text Item tool in the Layout Editor • Using the Create icon in the Object Navigator • Using the wizards How to Create a Text Item in the Layout Editor 1 Invoke the Layout Editor. It is important to point to the correct data block where you want to create the text item. In the Layout Editor, select the data block from the Block pop-up list. 2 Click the Text Item tool. 3 Click the canvas. The text item appears. 4 Double-click the text item. The text item Property Palette appears. 5 Set the item properties as required. How to Create a Text Item in the Object Navigator 1 Locate the block in which you want to create the item. 2 Select the Items node. 3 Click the Create icon. A new item entry is displayed in the Object Navigator. 4 Double-click the icon to the left of the new item entry. The Property Palette appears. 5 Set the Type property to Text Item. 6 Set all other item properties as required. Note: To display an item at run time, you must assign the item to a canvas. Do this in the Property Palette of the text item by setting the Canvas property to the desired canvas.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 6-7

Lesson 6: Working with Text Items ......................................................................................................................................................

Modifying the Appearance of a Text Item Order

Item Distance between records Number of items displayed Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Demonstration Using the ordwk05.fmb file, show how to alter the width and height of a text item. Show how to change the number of items displayed at run time.

...................................................................................................................................................... 6-8 Oracle Forms Developer: Build Internet Applications I

Modifying the Appearance of a Text Item ......................................................................................................................................................

Modifying the Appearance of a Text Item The properties of an item are divided into several groups. You can affect the way the text item is displayed by altering its General, Physical, Records, and Font and Color group properties. General Property Item Type

Function Selects the type of item you want to create

Physical Property Visible Canvas Tab Page X Position

Function Determines whether the item is displayed Determines on which canvas the item is displayed Determines the tab page on which the item is located Sets the X coordinate of the item relative to the canvas (bitmapped) or the screen (character) Sets the Y coordinate of the item relative to the canvas (bitmapped) or the screen (character) Sets the width of the text item in the current form coordinate units Sets the height of the text item in the current form coordinate units Sets the sculpted appearance of the item border Conserves system resources (When a rendered item no longer has focus, the resources used to display it are released.) Determines whether a vertical scroll bar appears for the multiline text item

Y Position Width Height Bevel Rendered

Show Vertical Scrollbar

Records Property Current Record Visual Attribute Group Distance Between Records Number of Items Displayed

Function Specifies the name of the visual attribute to use when the item is part of the current record Specifies the amount of space between instances of the item in a multirecord data block Specifies the number of item instances displayed for the item when the item is in a multirecord block

Note: When the Canvas property of an item is left unspecified, it is said to be a Null canvas item. It will not display at run time or in the Layout Editor.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 6-9

Lesson 6: Working with Text Items ......................................................................................................................................................

Font and Color Properties

Use properties in the Font and Color group to specify an item’s:

• •

Visual attributes Font name, size, weight, style, color, and pattern

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note When the form module does not contain any named visual attribute objects, the pop-up list for the Visual Attribute Group property shows only Default. An item that has the Visual Attribute Group property set to default, or that has individual attribute settings left unspecified, inherits those settings from the canvas to which it is assigned.

...................................................................................................................................................... 6-10 Oracle Forms Developer: Build Internet Applications I

Modifying the Appearance of a Text Item ......................................................................................................................................................

Font and Color Property Visual Attribute Group

Function Specifies how the item’s individual visual attributes are derived (Select Default or Named.) Font Name Specifies the font family (The list of fonts available is system dependent.) Font Size Specifies the font size in points Font Weight Specifies the weight of the font Font Style Specifies the font style Font Spacing Specifies the width of the font (This is the amount of space between characters.) Foreground Color Specifies the foreground color for the item Background Color Specifies the background color for the item Fill Pattern Specifies the pattern for the item fill region Character Mode Logical Attribute Specifies the name of the Oracle Terminal resource file attribute that sets the attributes of the device when running in character mode White on Black Determines whether the item appears as white text on a black background when displayed on a monochrome device

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 6-11

Lesson 6: Working with Text Items ......................................................................................................................................................

Prompts •

Prompts specify the text label that is associated with an item.



Several properties are available to arrange and manage prompts.



Use prompt properties of an item to change the prompt’s display style, justification, alignment, color, and font.

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 6-12 Oracle Forms Developer: Build Internet Applications I

Modifying the Appearance of a Text Item ......................................................................................................................................................

Prompt Property

Function

Prompt

Specifies the text label for the item

Prompt Display Style

Specifies the display style of the prompt (Choose among First Record, Hidden, and All Records.)

Prompt Justification

Specifies how the prompt is justified

Prompt Attachment Edge

Specifies the item edge to which the prompt is attached

Prompt Alignment

Specifies how the prompt is aligned along the item edge (Choose among: Start, End, and Center.)

Prompt Attachment Offset

Specifies the distance between the item and its prompt

Prompt Alignment Offset

Specifies the alignment offset of the prompt

Prompt Reading Order

Specifies the prompt order (Choose among: Default, Left To Right, and Right To Left.)

Prompt Font and Color Properties

Function

Prompt Visual Attribute Group

Specifies the named visual attribute that should be applied to the item prompt at run time

Prompt Font Name

Specifies the font family or typeface of the item prompt

Prompt Font Size

Specifies the size of the prompt font, in points

Prompt Font Weight

Specifies the weight of the prompt font

Prompt Font Style

Specifies the style of the prompt font

Prompt Font Spacing

Specifies the amount of space between characters

Prompt Foreground Color

Specifies the prompt text color

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 6-13

Lesson 6: Working with Text Items ...................................................................................................................................................... .

Associating Text with an Item Prompt 3

1 2

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 6-14 Oracle Forms Developer: Build Internet Applications I

Associating Text with an Item Prompt ......................................................................................................................................................

Associating Text with an Item Prompt The enhanced Form Builder Layout Editor has a tool called Associate Prompt which enables you to create a prompt for an item using any boilerplate text in the editor. In order to create a prompt-item association using the Associate Prompt tool, do the following: 1 Open the Layout Editor window. 2 Select the item and boilerplate text you want as the item’s prompt in the editor. 3 Click the Associate Prompt tool. Note: Users are able to create text items with a border but without a bevel by setting the Bevel property to Plain. In releases prior to Release 6.0, if bevel for a text item was removed, the border was also removed.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 6-15

Lesson 6: Working with Text Items ......................................................................................................................................................

Synchronize with Item Property

1

2

Copyright  Oracle Corporation, 2000. All rights reserved.

1

Synchronize with Item property set to Description item

2

Number of Items Displayed property set to 1

Instructor Note • The number of characters a text item can display is determined by a combination of factors, including the width of the text item, the font attributes, and the run-time platform. • Form Builder assigns a default value whenever the item is part of a record whose status is marked as NEW (when a new record is created). • If a text item is based on a column with a NOT NULL constraint, Form Builder automatically sets the Required property of the item to Yes. • You can use the Synchronize with Item property to create more than one item in a data block that displays the same database column values. • When data blocks are related through a compound join, the Copy Value from Item property is set on two or more foreign-key items in the detail data block.

...................................................................................................................................................... 6-16 Oracle Forms Developer: Build Internet Applications I

Controlling the Data of a Text Item ......................................................................................................................................................

Controlling the Data of a Text Item Use the data group properties of a text item to control the way the data is displayed and entered. Data Property Data Type Maximum Length Fixed Length Initial Value Required Format Mask Lowest Allowed Value Highest Allowed Value Copy Value from Item

Synchronize with Item

Function Determines what kinds of values Form Builder allows as input into the item Sets the maximum number of characters allowed in the item (This usually corresponds to the column width for base table items.) Determines whether the user is required to fill the item completely before being able to move into another item Specifies the default value that Form Builder gives to the item for each new record Determines whether the item is mandatory; that is, whether it is based on a NOT NULL column constraint in the underlying table Specifies a format for the text item Sets the minimum value allowed in this item Sets the maximum value allowed in this item Specifies the block and item to use as the source for copying a value into this item when focus is set on one of its records (used in interblock relations) Specifies the name of the item from which the current item derives its value (This property means that you can have two items in a block that simultaneously represent the same base table column, thus mirroring each other.)

Note • If the Maximum Length exceeds the display width of the item, Form Builder automatically enables the end user to scroll the contents of the item horizontally, so that the cursor remains visible. • When Fixed Length is set to Yes, a text item is valid only if it contains the number of characters specified in the Maximum Length property. • Form Builder accepts NULL values in a fixed length text item, provided the text item does not have its Required property set to Yes. • Use only CHAR, NUMBER, DATE, and LONG data types. All other data types are available for compatibility with earlier versions of Oracle Forms Developer.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 6-17

Lesson 6: Working with Text Items ......................................................................................................................................................

Copy Value from Item Property Dept

ORDERS

Id 31 Name

Region Id

1

Sales

Employee Id 3 11

Last Name Nagayama Magee

First Name Midori Colin

Title VP, Sales Sales Rep

Dept Id 31 31

Copyright  Oracle Corporation, 2000. All rights reserved.

Format Masks •



Standard SQL formats – Dates

FXDD-MON-YY

– Numbers

L099G99D99

Nonstandard formats Use double quotes for embedded characters "("099")"099"-"0999

Note: Allow for format mask’s embedded characters when defining Width property.

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 6-18 Oracle Forms Developer: Build Internet Applications I

Controlling the Data of a Text Item ......................................................................................................................................................

The Copy Value from Item Property Use the Copy Value from Item property to reference the source of the value that Forms uses to populate the current item. • Enter the block and item name from which Form Builder reads the value as follows: .. • Use this property to link data blocks. In a master-detail form module, Form Builder automatically sets this property for the foreign-key item in the detail data block to the primary-key item in the master data block. • In the Summit application, S_ITEM.ORD_ID has this property. Note: The text item should disable input; otherwise, the user could violate the foreign-key relationship. To prevent operators from deactivating the foreign-key relationship, set the Enabled property to No for the foreign-key item. Formatting a Text Item Use the Format Mask property to specify the format in which the user sees the item value. • Use standard SQL formatting syntax for dates and numbers; for example, DD/MM/YY and $99,999.99. • Enclose non-SQL standard embedded characters in double quotes; for example, hyphen (-) and comma (,). Note: It is recommended that you avoid creating individual masks if the general purpose masks (see Lesson 1) will suffice. FX Format Mask The FX format mask in a date value ensures that the date is entered exactly as defined in the mask. Element D is for decimal, and G is a group separator. Example With a date format of DD/MM/YY, valid entries are: • 10/12/00 • 10 12 00 • 10-DEC-00 • 101200 Note: You can enter any character to represent the (/) in the value. Allow for the embedded characters of the format mask when defining the Width property. The embedded characters are used only for purposes of display and are not stored in the database.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 6-19

Lesson 6: Working with Text Items ......................................................................................................................................................

Initial Values • • • •

Are used for every new record Can be overwritten Must be compatible with item’s data type Use: – Raw value – System variable – Global variable – Form parameter – Form item – Sequence Copyright  Oracle Corporation, 2000. All rights reserved.

Initial Values The initial value must be compatible with the item data type. If the Lowest/Highest Allowed values are specified, the initial value cannot be outside the range.

...................................................................................................................................................... 6-20 Oracle Forms Developer: Build Internet Applications I

Controlling the Data of a Text Item ......................................................................................................................................................

Creating an Initial Value Use any one of the following values to issue an initial item value whenever a new record is created: • Raw value Example: 340, RICHMOND • System variable - Variables giving current operating system date/time: Variable

Format

$$DATE$$

DD-MON-YY

$$DATETIME$$

DD-MON-YYYY hh:mi[:ss]

$$TIME$$

hh:mi[:ss]

-

• • • •

Variables giving current database date/time:

Variable

Format

$$DBDATE$$

DD-MON-YY

$$DBDATETIME$$

DD-MON-YYYY hh:mi[:ss]

$$DBTIME$$

hh:mi[:ss]

Global variable Example: :GLOBAL.CUSTOMER_ID Form parameter Example: :PARAMETER.SALES_REP_ID Form item Example: :ORDER.ID Sequence Example: :SEQUENCE.S_ORD_ID.NEXTVAL

Automatic Sequence Number Generation The initial value can reference a sequence in the database. Form Builder automatically writes generated sequence numbers into the text item.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 6-21

Lesson 6: Working with Text Items ......................................................................................................................................................

Navigational Behavior of Text Items • •

Established by order of entries in Object Navigator Controlled by: – Keyboard Navigable – Previous Navigation Item – Next Navigation Item

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 6-22 Oracle Forms Developer: Build Internet Applications I

Altering the Navigational Behavior of a Text Item ......................................................................................................................................................

Altering the Navigational Behavior of a Text Item You can see the default navigational sequence of items in the Object Navigator, as the item entries are displayed in the navigational order. However, you can also use the Navigation group properties to control the navigational behavior of a text item. Navigation Property Keyboard Navigable

Previous Navigation Item Next Navigation Item

Function Determines whether you can navigate to an item during default navigation with the function keys or menu items and place input focus on it (When this property is set to No, Form Builder skips over the item and enters the next navigable item in the default navigation sequence.) Determines the previous item to be visited when you navigate out of the current item Determines the next item to be visited when you navigate out of the current item

Note: The next or previous navigation item must be in the same data block as the current item.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 6-23

Lesson 6: Working with Text Items ......................................................................................................................................................

Database Properties

Use properties in the Database group to control:

• • • •

Item’s data source—base table item or control item Query, insert, and update operations on an item Maximum query length Query case

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note • Setting Case Insensitive Query to Yes may take queries longer to execute. • Update Allowed must be set to No before setting Update Only if NULL to Yes. • When might Update Only if NULL be used? For a value that can be set only once. For example, it might be used for a ship date. Once an order is shipped the ship date cannot be modified.

...................................................................................................................................................... 6-24 Oracle Forms Developer: Build Internet Applications I

Enhancing the Relationship Between Text Item and Database ......................................................................................................................................................

Enhancing the Relationship Between Text Item and Database You can alter or enhance the way in which a text item interacts with its corresponding database column by setting the Database group properties. Database Property Database Item

Function Determines whether the item value is stored in the block base table as opposed to being a control item Column Name Establishes that the item corresponds to a column in the table associated with the data block Primary Key Indicates that the item is a base table item and that it corresponds to a primary key column in the base table (Its value must be unique.) Query Only Specifies that the item can be queried but not included in an INSERT or an UPDATE statement Query Allowed Determines whether the item can accept query criteria Query Length Sets the maximum length of a query expression for the item (Enter Query mode) (This may not be set to a value lower than that of the Maximum Length, unless set to zero.) Case Insensitive Query Determines whether the difference between upper, mixed, and lowercase values is recognized during query processing Insert Allowed Determines whether the item allows values to be inserted (This property applies only to new records.) Update Allowed Determines whether the item allows updates Update Only If NULL Determines whether the item allows updates only when the current value is NULL (This property applies to existing records only.) Lock Record Determines whether the record is locked when the item is modified (This property applies only to nonbase table items.)

Note: When you create an item in a data block, Form Builder assumes the item is a data item and sets its Database Item property to Yes. Data items are automatically included in any SELECT, UPDATE, and INSERT statements issued to the database. If an item you are creating is a control item, you must explicitly set its Database Item property to No.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 6-25

Lesson 6: Working with Text Items ......................................................................................................................................................

Functional Properties Enabled=No Order Order Id 100

Case Restriction= Upper Payment CREDIT Type

Date 31-aug-1992 Ordered

Date Shipped 10-sep-1992 Item Justification = Start Id

Justification = Right

Product Id

Price

Shipped

Item Total

1

10011

135

500

2

10013

380

400 152,000.00

67,500.00

Copyright  Oracle Corporation, 2000. All rights reserved.

Conceal Data Property

Log Screen

Enter Userid: Enter Password:

scott *****

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 6-26 Oracle Forms Developer: Build Internet Applications I

Adding Functionality to a Text Item ......................................................................................................................................................

Adding Functionality to a Text Item Add to the default functionality of a text item by introducing some of the additional features: Functional Property Enabled

Justification Multi-Line

Wrap Style Case Restriction Conceal Data

Keep Cursor Position Automatic Skip

Popup Menu

Function Determines whether you can navigate to an item and manipulate it with the mouse (When this property is set to No, the item is disabled and appears grayed out on most window managers.) Determines the text justification of the value within the item Determines whether the item can store multiple lines of text (Text items can be multiline only if they represent a VARCHAR2, or long base table column.) Determines whether a multiline text item wraps onto the next line; choose from None, Character, or Word Forces the case of the user’s input to Upper, Lower, or Mixed Determines whether the value in the item is echoed to the screen and hence visible to the user (This setting is typically used for password protection.) Retains the cursor position so that when you reenter an item, it is in the same place Determines whether the cursor automatically skips into the next item when this one is full (Auto Skip is used in conjunction with the Fixed Length property.) Specifies the pop-up menu within the current form module to display for the item

Note: The Enabled property set to No grays out the item. If you want the item to appear normally but do not want the users to change it, do the following: • Set Insert Allowed to No. • Set Update Allowed to No. • Set Enabled to Yes. Note: A pop-up menu is a context-sensitive menu that enables users to access common functions and commands quickly. It is a top-level object in the Object Navigator and belongs to a form module. Technical Note A pop-up menu belongs to the form module, as opposed to a form menu, which belongs to a separate menu module.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 6-27

Lesson 6: Working with Text Items ......................................................................................................................................................

Keyboard Navigable and Enabled Properties •

Set both properties to allow or disallow navigation and interaction with text item.



When Enabled is set to Yes, Keyboard Navigable can be set to Yes or No.



When Enabled is set to No, the item is always nonnavigable.

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Demonstration Using the ordwk05.fmb file, show the run-time effects of changing the Enabled, Justification, Multi-Line, Case Restriction, Conceal Data, and Automatic Skip properties.

...................................................................................................................................................... 6-28 Oracle Forms Developer: Build Internet Applications I

Adding Functionality to a Text Item ......................................................................................................................................................

Setting Keyboard Navigable and Enabled Properties You can set the Keyboard Navigable and Enabled properties for items to specify whether operators can navigate to and interact with them. Enabled Yes

Keyboard Navigable Yes

Yes

No

No

No

No

Yes

Navigation Behavior Item is included during default navigation. The item can be navigated to and manipulated with the mouse. Item is excluded during default navigation. The item can be navigated to and manipulated with the mouse. Item is excluded during default navigation. The item cannot be navigated to or manipulated with the mouse. Item is excluded during default navigation. The item cannot be navigated to or manipulated with the mouse. The Keyboard Navigable property is also effectively set to No.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 6-29

Lesson 6: Working with Text Items ......................................................................................................................................................

Multiline Text Items

Width Text Height

Text Text Text

Total text = Maximum length

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 6-30 Oracle Forms Developer: Build Internet Applications I

Adding Functionality to a Text Item ......................................................................................................................................................

Creating a Multiline Text Item Use multiline text items to display the following: • Addresses • Comments • Descriptions The data in a multiline text item must be one of the following types: • Char • Alpha • Long When creating a multiline text item, consider the following properties: • Width • Height • Font Size • Maximum Length • Show Vertical Scroll Bar To see the desired number of lines, you need to alter the default values for the aforementioned properties; otherwise, the text item merely has the ability to store multilined data. The number of characters that can fit on one line is dictated by the width of the text item and the font in use. Setting the Justification You can specify how text values are aligned in a text item by setting the Justification property to Left, Right, Center, Start, or End. Note: Some window managers do not display right-aligned or centered text. Setting right or center alignment for scrollable text items may result in values being hidden from the user.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 6-31

Lesson 6: Working with Text Items ......................................................................................................................................................

Help Properties

Hint

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Tool tips are discussed in Lesson 9.

...................................................................................................................................................... 6-32 Oracle Forms Developer: Build Internet Applications I

Including Helpful Messages ......................................................................................................................................................

Including Helpful Messages Use the Help group properties to provide context-sensitive help to your user: Help Property Hint

Display Hint Automatically

Function Writes item-specific Help text that is displayed on the message line at run time (The Help text is available when input focus is on the item.) Determines whether the hint for the item is displayed automatically

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 6-33

Lesson 6: Working with Text Items ......................................................................................................................................................

Summary • • • • • • •

Creating a text item Modifying appearance Controlling data Altering navigational behavior Enhancing relationship with database Adding functionality Including context-sensitive Help

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 6-34 Oracle Forms Developer: Build Internet Applications I

Summary ......................................................................................................................................................

Summary This lesson showed you how to create and modify a text item that Form Builder creates for each column flagged for inclusion in a data block. In particular, text items have properties that enable you to do the following: • Modify their appearance • Control the data stored in the item • Alter navigational behavior • Enhance the relationship with the database • Add functionality • Include Help information

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 6-35

Lesson 6: Working with Text Items ......................................................................................................................................................

Practice 6 Overview

This practice covers the following topics:

• • •

Deleting text items Modifying text item properties Creating text items

Copyright  Oracle Corporation, 2000. All rights reserved.

Note For solutions to this practice, see Practice 6 in Appendix A, “Practice Solutions.”

...................................................................................................................................................... 6-36 Oracle Forms Developer: Build Internet Applications I

Practice 6 Overview ......................................................................................................................................................

Practice 6 Overview In this practice session you will create text items, alter the behavior and the appearance of text items, and delete text items. • Delete the region ID item in the CUSTOMERS form. • Using the Property Palette, change the properties of several text items in the S_CUSTOMER data block to change their run-time appearance. Save and run the form after the changes are applied. • In the ORDERS form, create new text items to hold the customer name and sales rep name values in the S_ORD block, and set the suggested properties. Change additional text item properties in the S_ORD, S_ITEM, and S_INVENTORY data blocks to change their run-time appearance and behavior. Save and run the form after the changes are applied.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 6-37

Lesson 6: Working with Text Items ......................................................................................................................................................

Practice 6 CUSTGXX Form 1 Remove the Region ID item. 2 Make sure that the Comments item allows multiline text to display. 3 Automatically display a unique, new customer number for each new record and ensure that it cannot be changed. Use the S_CUSTOMER_ID sequence. Note: This is not the only way to do this. Other methods are shown in later lessons. 4 In the CUSTGXX form, resize and reposition the items. Reorder the items in the Object Navigator. Use the screenshot and the table below as a guide. Resize items by setting the width according to the following property table. Item ID NAME ADDRESS CITY STATE COUNTRY ZIP_CODE PHONE CREDIT_RATING SALES_REP_ID COMMENTS

Suggested Width 60 195 195 195 130 195 85 160 65 65 236

...................................................................................................................................................... 6-38 Oracle Forms Developer: Build Internet Applications I

Practice 6 ......................................................................................................................................................

5 Save and compile your form.

Deploy the form on the Web to test the changes.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 6-39

Lesson 6: Working with Text Items ......................................................................................................................................................

ORDGXX Form 6 In the S_ORD block, create a new text item called Customer_Name. Ensure that Customer_Name is not associated with the S_ORD table. Do not allow insert, update, or query operations on this item, and make sure that navigation is possible only by means of the mouse. Set the Prompt text to Customer Name. Display this item on CV_ORDER canvas. 7 In the S_ORD block, create a new text item called Sales_Rep_Name. Ensure that Sales_Rep_Name is not associated with the S_ORD table. Do not allow insert, update, or query operations on this item and make sure that navigation is possible only by means of the mouse. Set the Prompt text to Sales Rep Name. Display this item on the CV_ORDER canvas. 8 Set the relevant property for Date_Ordered, so that it displays the current date whenever a new record is entered. 9 In the S_ITEM block, create a new text item called Item_Total. Ensure that Item_Total is not associated with the S_ITEM table. Do not allow insert, update, or query operations on this item and make sure that navigation is possible only by means of the mouse. Allow numeric data only and display it by using a format of 999G990D99. Set the Prompt text to Item Total. Display this item on the CV_ORDER canvas. 10 Justify the values of Price, Quantity, and Quantity_Shipped to the right. 11 Alter the Quantity_Shipped item, so that navigation is possible only by means of the mouse and updates are not allowed.

...................................................................................................................................................... 6-40 Oracle Forms Developer: Build Internet Applications I

Practice 6 ......................................................................................................................................................

12 In the ORDGXX form, resize and reposition the items according to the

screenshot and the table below. Resize the items by setting the width in the corresponding property palette. Drag and drop the items to reposition: S_ORD Block Items ID DATE_ORDERED CUSTOMER_ID CUSTOMER_NAME SALES_REP_ID SALES_REP_NAME DATE_SHIPPED PAYMENT_TYPE ORDER_FILLED

Suggested Width 40 66 66 116 66 116 66 48 18

S_ITEM Block Items ITEM_ID PRODUCT_ID PRICE QUANTITY QUANTITY_SHIPPED ITEM_TOTAL

Suggested Width 20 40 42 26 26 86

Instructor Note Customer_Name and Sales_Rep_Name are created as text items in this course. They could also be created as display items. Display items use less memory than text items.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 6-41

Lesson 6: Working with Text Items ......................................................................................................................................................

...................................................................................................................................................... 6-42 Oracle Forms Developer: Build Internet Applications I

Practice 6 ......................................................................................................................................................

13 In the S_INVENTORY block, alter the number of instances of the

Product_ID so that it is displayed just once. 14 Arrange the items and boilerplate on CV_INVENTORY, so that it resembles the screenshot. Hint: Set the Update Layout property for the frame to Manually.

15 Save, compile, and run the form to test the changes.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 6-43

Lesson 6: Working with Text Items ......................................................................................................................................................

...................................................................................................................................................... 6-44 Oracle Forms Developer: Build Internet Applications I

7 ................................

Creating LOVs and Editors

Lesson 7: Creating LOVs and Editors ......................................................................................................................................................

Objectives

After completing this lesson, you should be able to do the following:

• •

Describe LOVs and editors



Create editors and associate them with text items in a form module

Design, create, and associate LOVs with text items in a form module

Copyright  Oracle Corporation, 2000. All rights reserved.

Schedule Topic Lecture Practice Total

Timing 50 minutes 30 minutes 80 minutes

...................................................................................................................................................... 7-2 Oracle Forms Developer: Build Internet Applications I

Introduction ......................................................................................................................................................

Introduction Overview With Oracle Forms Developer you can enhance your application with lists of available values and text editors to supplement the text item object. In this lesson you will learn how to create lists of values (LOVs) and text editors, and to associate them with items in your application.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 7-3

Lesson 7: Creating LOVs and Editors ......................................................................................................................................................

LOVs and Editors Editor

Text item

Text item

Text item

LOV

Supporting data record group Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 7-4 Oracle Forms Developer: Build Internet Applications I

What Are LOVs and Editors? ......................................................................................................................................................

What Are LOVs and Editors? Lists of values (LOV) and editors are objects in a form module that each open their own window when activated at run time. They are defined at the form level, which means you can use them to support text items in any block of the form module. LOVs An LOV is a scrollable pop-up window that provides a user with a simple mechanism to pick the value of an item from a multicolumn dynamic list. The user can reduce the lines displayed in the list by simple automatic reduction techniques, or by search strings. Each line in an LOV can present several field values, with column headings above. You can design your LOV to retrieve some or all of the field values from the line chosen by the user, and place them into form items or variables. LOVs have the following qualities: • Dynamic: The list entries can change to reflect changes in the source data. • Independent: The designer can invoke an LOV from any text item, or from outside a text item if called programmatically. • Flexible: You can use the same LOV to support several items, if appropriate (for example, product_ID, product_name). • Efficient: You can design LOVs to reuse data already loaded into the form, instead of accessing the database for every call. This is useful where data is relatively static.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 7-5

Lesson 7: Creating LOVs and Editors ......................................................................................................................................................

LOVs and Editors •

LOVs – List of values for text items – Dynamic or static list – Independent of single text items – Flexible and efficient



Editors – Override default editor – Used for special requirements such as larger editing window, position, color, and title – System editor available as an option Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note • Pressing the [Delete Backward] key expands the reduced list of choices in the LOV. To find a key to match Delete Backward, select Help—>Keys to display Keys list. • The EDIT_TEXTITEM built-in invokes the editor associated with the current text item. The SHOW_EDITOR built-in invokes a user-named editor at the specified display coordinates.

...................................................................................................................................................... 7-6 Oracle Forms Developer: Build Internet Applications I

What Are LOVs and Editors? ......................................................................................................................................................

How to Use an LOV at Run Time When a text item has an LOV attached, the List of Values lamp displays on the status line, while the cursor is in the item. 1 Either press the List of Values key, or select Edit>Display List to invoke the LOV. 2 Select an entry in the displayed list. You can type characters to automatically reduce the list, or enter a search string in the Find field. 3 Click OK to retrieve the line value. Note: Automatic reduction works by comparing the search string entered with the values displayed in the first column of the LOV. If you start your search criteria with a % symbol, Form Builder performs a search on all LOV columns. Editors With a text editor enabled the user can view multiple lines of a text item simultaneously, search and replace text in it, and generally modify the value of an item from this separate window. You can use one of three editors at run time: • Form Builder default editor • User-named editor • System editor Every text item has the default editor available, but you can design your own replacement editor for those items that have special requirements such as larger editing window, position, color, and title. By overriding the default editor for a text item, you can provide a larger editing window for items with potentially large textual values. Optionally, use an external system editor. How to Use an Editor at Run Time With the cursor in the text item to be edited, follow these steps: 1 Press the Edit key, or select Edit>Edit to invoke the attached editor. 2 Edit the text in the Editor window. Form Builder editors provide a Search button that invokes an additional search-and-replace dialog box for manipulating text. 3 Click OK to write your changes back to the text item.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 7-7

Lesson 7: Creating LOVs and Editors ......................................................................................................................................................

LOVs and Record Groups Text item

Text item

LOV

LOV

Record group Record group based on static data

OR

Record group Query-based record SQL group

Database Copyright  Oracle Corporation, 2000. All rights reserved.

LOVs Customers LOV

name

id

phone city

Customers record group

S_CUSTOMER table SELECT SELECT name, name, id, id, phone, phone, city city FROM s_customer FROM s_customer ORDER ORDER BY BY name name Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 7-8 Oracle Forms Developer: Build Internet Applications I

Defining an LOV ......................................................................................................................................................

Defining an LOV Designing an LOV When you build an LOV, consider the following objects: • Record group: A Form Builder object that is used to store the array of values that are presented by an LOV (The record group can be created first or as part of the LOV creation process if based on a query.) • LOV: The list itself, which presents one or more column values from the supporting record group in the LOV window (It enables the user to select values, and then write values back to specified items or variables.) Text items: The main text item that you attach to an LOV is usually one that the LOV returns a value to. You can call the LOV from this item to provide possible values for it. A single LOV can return values to several items, and you may want to attach it to these items as well in your application. In fact, you can attach the LOV to any text item from which the same list of values needs to be viewed, whether or not it will receive a value. Record Groups A record group is a column-and-row structure stored within Forms Runtime memory and is similar to the structure of a database table. It holds records that can be reused by other Oracle Forms Developer applications and Oracle Reports Developer applications, hence reducing repeated access to external data. Record groups can be designed to contain static values. Alternatively, they can be populated programmatically at run time or, most commonly, populated by a SQL query. In this lesson, you use record groups to support LOVs. Record groups can provide the following: • Data that is presented by LOVs • Data for dynamic list items • Data to be passed to Report Builder and Graphics Builder • Other application-defined uses Note: Because LOVs and record groups are separate objects, you can create multiple LOVs based on the same record group.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 7-9

Lesson 7: Creating LOVs and Editors ...................................................................................................................................................... \

Creating an LOV Using the LOV Wizard: SQL Query Page

Copyright  Oracle Corporation, 2000. All rights reserved.

Creating an LOV Using the LOV Wizard: Column Selection Page

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 7-10 Oracle Forms Developer: Build Internet Applications I

Creating an LOV by Using the LOV Wizard ......................................................................................................................................................

Creating an LOV by Using the LOV Wizard 1 Launch the LOV Wizard.

The Welcome page is displayed. Click Next. 2 Specify the LOV source in the LOV Source page. Choose an existing record group or create a new one based on a query. The New Record Group based on a query radio button is set by default. Click Next to select the default. 3 In the SQL Query page specify the query used to construct the record group. - Click the Build SQL Query button to use the Query Builder. - Click the Import SQL Query button to import a query from a file. - To enter the query directly, type the SQL syntax in the SQL Query Statement field. Then click the Check Syntax button. 4 In the Column Selection page, select the record columns that you want to include in the LOV. Note: See Appendix G for more information about Query Builder.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 7-11

Lesson 7: Creating LOVs and Editors ......................................................................................................................................................

Creating an LOV Using the LOV Wizard: Column Properties Page

Copyright  Oracle Corporation, 2000. All rights reserved.

Creating an LOV Using the LOV Wizard: Display Page

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 7-12 Oracle Forms Developer: Build Internet Applications I

Creating an LOV by Using the LOV Wizard ......................................................................................................................................................

Creating an LOV by Using the LOV Wizard (continued) 5 In the Column Properties page, specify the title, width and return value for each LOV column. Note that the Return Value Into item is optional. 6 In the LOV Display page, specify the title, width, and height of the LOV window.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 7-13

Lesson 7: Creating LOVs and Editors ......................................................................................................................................................

Creating an LOV Using the LOV Wizard: Advanced Properties Page

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note As in earlier releases of Oracle Forms Developer, an LOV can be created manually. Demonstrate this for the students. • Select the LOV node in the Object Navigator and click the Create icon. • Select Build a new LOV manually. A new LOV appears under the LOV node in the Object Navigator. • Invoke the property palette for the new LOV to set the required properties.

...................................................................................................................................................... 7-14 Oracle Forms Developer: Build Internet Applications I

Creating an LOV by Using the LOV Wizard ......................................................................................................................................................

Creating an LOV by Using the LOV Wizard (continued) 7 In the Advanced Options page, set the additional advanced properties. Specify: - The number of records to be fetched from the database - If the user should be presented with a dialog box to add criteria before the LOV is displayed - If the LOV records should be queried each time the LOV is invoked 8 In the Finish page, click Finish to complete the LOV creation process.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 7-15

Lesson 7: Creating LOVs and Editors ......................................................................................................................................................

LOV Properties (X,Y)

Width LOV Automatic Select

Height

Column Mapping

Filter Before Display Automatic Skip

?

Return Items

Automatic Display

Copyright  Oracle Corporation, 2000. All rights reserved.

LOV Properties LOV

Automatic Column Width Automatic Position

Column Mapping

Return Items

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 7-16 Oracle Forms Developer: Build Internet Applications I

Creating an LOV by Using the LOV Wizard ......................................................................................................................................................

Setting LOV Properties After you create an LOV, open its Property Palette to define its properties. Property Title X Position and Y Position

Function Specifies a title for the LOV Screen coordinates for the LOV window in the current form coordinate units (Choose a position that is suitable for the items that the LOV supports.) Width and Height Size of the LOV window in the current form coordinate units (The user can adjust this, but choose a size that is suitable for the data.) Column Mapping Properties Opens the LOV Column Mapping window (discussed later in (More . . . ) this lesson) Filter Before Display Determines whether users should be prompted with a dialog box that enables them to enter a search value before the LOV is invoked (This value is used as an additional restriction on the first column in the query.) Automatic Display Determines whether the LOV should be invoked automatically when the cursor enters an item to which the LOV is attached Automatic Refresh When this property is set to Yes, the record group reexecutes its query every time the LOV is invoked.

Automatic Select Automatic Skip

Automatic Position Automatic Column Width

When this property is set to No, the record group query fires only the first time the LOV is invoked within a user session. Subsequent LOV calls use current record group data (more efficient for data that will not change much.) Determines whether the LOV should close and return values automatically when reduced to a single entry Determines whether the cursor skips to the next navigable item when the operator selects a value from the LOV to populate the text item Determines whether Form Builder automatically positions the LOV near the field from which it was invoked Determines whether Form Builder automatically sets the width of each column to display the entire column title when the column title width is longer than the column display width

Note: More than one LOV can be based on the same record group. When this is the case and you set Automatic Refresh to No, Form Builder will not reexecute the LOV query once any of the LOVs is invoked.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 7-17

Lesson 7: Creating LOVs and Editors ......................................................................................................................................................

LOV Column Mapping customer.name

customer.id

customer.phone customer.city

Phone

City

809-352689 San Pedro De 1-415-555-6281 San Francisco 91-1031 New Delhi 52-404562 Nogales

Customers LOV

Hidden columns

name

S_CUSTOMER table SELECT SELECT FROM FROM ORDER ORDER BY BY

id

phone city

Customers record group

name, name, id, id, phone, phone, city city s_customer s_customer name name

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note • Do not put a colon in front of the Return Item object names. • To add extra spaces between columns in the LOV window, set the Display Width wider than the column default width. However, you cannot increase the width between a number column and a nonnumber column this way because LOVs display numbers right-justified. • You can also attach an LOV to a text item programmatically with the SET_ITEM_PROPERTY built-in.

...................................................................................................................................................... 7-18 Oracle Forms Developer: Build Internet Applications I

Creating an LOV by Using the LOV Wizard ......................................................................................................................................................

The Column Mapping Properties When you click the More property control button for Column Mapping Properties, the LOV Column Mapping dialog box opens. Column Mapping Element Column Names (List) Return Item

Description Lets you select an LOV column for mapping or defining a column Specifies the name of the form item or variable to which Form Builder should assign the column value. Use one of the following: block_name.item_name GLOBAL.variable_name PARAMETER.parameter_name

Display Width

Column Title

If null, the column value is not returned from LOV. Width of column display in LOV (A 0 value causes the column to be hidden, although its value remains available for return.) Heading for column in LOV window

To set a column mapping in this dialog, first select the column from the Column Names list, then set the other mapping values, as required. Note: The record group columns and LOV columns must remain compatible. You can modify the record group query from its own properties list. Associating an LOV with a Text Item So that the user can invoke an LOV from a text item, you must specify the LOV name in the Property Palette of the text item. 1 Select the text item in the Object Navigator from which the LOV is to be accessible. 2 In the item Property Palette, set the List of Values property to the required LOV. Remember that the List of Values lamp is displayed when the user navigates to this text item, indicating that the LOV is available through the List of Values key or menu command.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 7-19

Lesson 7: Creating LOVs and Editors ......................................................................................................................................................

Editors

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Demonstration Show how to create an editor.

...................................................................................................................................................... 7-20 Oracle Forms Developer: Build Internet Applications I

Defining an Editor ......................................................................................................................................................

Defining an Editor If the user needs to use an editor on text values, the default Form Builder editor is usually sufficient for most items. However, you can design your own customized editor as an object in a form module, and then attach it to the text items that need it. How to Create a Customized Editor 1 Select the Editors node in the Object Navigator, then click Create. A new editor object is displayed in the list. 2 Select the new editor in the Object Navigator, and then access its Property Palette, where you can set its name and other properties. The following properties show the individual tailoring that is possible by creating your own editor. Properties are abridged and summarized. Property Title/Bottom Title Width/Height X Position/Y Position Wrap Style

Show Vertical Scroll Bar

Function Displays at top or bottom of editor window These properties control the size of the editor and hence its editing area Screen position for window; can also be defined by a text item property Specifies how text is displayed when a line of text exceeds the width of the editing area (Choose among None, Character, or Word.) To add a vertical scroll bar to the editor, specify Yes for this property.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 7-21

Lesson 7: Creating LOVs and Editors ......................................................................................................................................................

Editors •

Associate one of three types of editors with a text item.



Set text item’s Editor property to one of the following: – Null (default Form Builder editor) – editor_name (customized editor) – SYSTEM_EDITOR (external editor)

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 7-22 Oracle Forms Developer: Build Internet Applications I

Defining an Editor ......................................................................................................................................................

Associating an Editor with a Text Item To associate an editor with a text item, you must specify the editor in the Property Palette of the text item. Select the text item in the Object Navigator from which the editor is to be accessible. In the item Property Palette, set the Editor property to one of the following settings: • Null: The text item uses the default Form Builder editor. • editor_name: The text item uses the named editor that you have created and customized in this module. • SYSTEM_EDITOR: The item uses the external ASCII editor defined in the system editor environment variable (which varies according to platform).

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 7-23

Lesson 7: Creating LOVs and Editors ......................................................................................................................................................

Summary • • • •

LOVs and editors are form objects. LOVs and editors can be shared across text items. There are three steps to implement an LOV. Text items can use the default editor, a custom editor, or a system editor.

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 7-24 Oracle Forms Developer: Build Internet Applications I

Summary ......................................................................................................................................................

Summary In the lesson you learned that lists of values (LOVs) and text editors can be used to support text items. Both LOVs and editors are objects in a form module that open their own window when activated at run time and are used to support text items in any block of the form module. • LOVs and editors can be shared across text items. • The steps to implement an LOV are: a Create a new LOV (and record group). b Define column mapping for return items. c Attach the LOV to text items, as required. • Text items can use the default editor, a user-named editor, or a system editor.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 7-25

Lesson 7: Creating LOVs and Editors ......................................................................................................................................................

Practice 7 Overview

This practice covers the following topics:



Creating an LOV and attaching the LOV to a text item



Creating an editor and attaching the editor to a text item

Copyright  Oracle Corporation, 2000. All rights reserved.

Note For solutions to this practice, see Practice 7 in Appendix A, “Practice Solutions.”

...................................................................................................................................................... 7-26 Oracle Forms Developer: Build Internet Applications I

Practice 7 Overview ......................................................................................................................................................

Practice 7 Overview In this practice session, you will create two LOVs and an editor. • Using the LOV Wizard, create an LOV in the ORDERS form to display product numbers and their descriptions. Attach the LOV to the Product_ID item in the S_ITEM data block. Save and run the form. • Using the LOV wizard, create an LOV in the CUSTOMERS form to display sales representatives’ numbers and their names. Attach the LOV to the Sales_Rep_ID item in the S_CUSTOMER data block. Save and run the form. • Create an editor in the CUSTOMERS form, and attach it to the Comments item. Save and run the form.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 7-27

Lesson 7: Creating LOVs and Editors ......................................................................................................................................................

Practice 7 1 In the ORDGXX form, create an LOV using the LOV Wizard to display

2 3

4

5

product numbers and descriptions to be used with the Product_Id item in the S_ITEM block. Use the S_PRODUCT table, Id, and Name columns. Assign a title of Products to the LOV. Assign a column width of 25 for ID, and assign the LOV width of 200 and a height of 250. Position the LOV 30 pixels below and to the right of the upper lefthand corner. For the ID column, set the return item to S_ITEM.PRODUCT_ID. Attach the LOV to the Product_Id item in the S_ITEM block. Change the name of the LOV to PRODUCTS_LOV. Save and compile your form. Deploy the form on the Web to test the changes. In the CUSTGXX form, create an LOV to display sales representatives’ numbers and their names, using the LOV Wizard. Use the S_EMP table, Id, First_Name, and Last_Name columns. Concatenate the First_Name and the Last_Name columns and give an alias such as Name. Assign a title of Sales Representatives to the LOV. Assign a column width of 20 for ID, and assign the LOV a width of 200, and a height of 250. Position the LOV 30 pixels below and to the right of the upper lefthand corner. For the ID column, set the return item to S_CUSTOMER.SALES_REP_ID. Attach the LOV to the Sales_Rep_Id item in the S_CUSTOMER block. Change the name of the LOV to SALES_REP_LOV. In the CUSTGXX form, create an editor and attach it to the Comments item. Set the title to Comments, the background color to gray, and the foreground color to yellow. Save, compile, and run the form to test the changes. Resize the window if necessary.

...................................................................................................................................................... 7-28 Oracle Forms Developer: Build Internet Applications I

8 ................................

Creating Additional Input Items

Lesson 8: Creating Additional Input Items ......................................................................................................................................................

Objectives

After completing this lesson, you should be able to do the following:

• • • •

Identify the item types that allow input Create a check box Create a list item Create a radio group

Copyright  Oracle Corporation, 2000. All rights reserved.

Schedule Topic Lecture Practice Total

Timing 60 minutes 45 minutes 105 minutes

...................................................................................................................................................... 8-2 Oracle Forms Developer: Build Internet Applications I

Introduction ......................................................................................................................................................

Introduction Overview In addition to text items, Oracle Forms Developer provides a variety of other item types. These can be divided into two groups: those that accept input and those that do not. This lesson covers input items and how they are used.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 8-3

Lesson 8: Creating Additional Input Items ......................................................................................................................................................

Input Items •

Item types that accept user input include: – Check boxes – List items – Radio groups



Input items enable insert, update, delete, and query.

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 8-4 Oracle Forms Developer: Build Internet Applications I

What Are Input Items? ......................................................................................................................................................

What Are Input Items? Input item is a generic term for Form Builder item types that accept user input. These item types include the following: • Check box • List item • Radio group What Can You Do with Input Items? When you create input items, they already have some initial functionality. Through items you can interact with the database in the following ways: • Insert values • Update existing values • Delete existing values • Query existing values Note: You can add functionality to input items with triggers and PL/SQL program units.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 8-5

Lesson 8: Creating Additional Input Items ......................................................................................................................................................

Check Boxes •

Two-state interface object: – Checked – Unchecked



Not limited to two values

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 8-6 Oracle Forms Developer: Build Internet Applications I

Creating a Check Box ......................................................................................................................................................

Creating a Check Box What Is a Check Box? A check box is a two-state interface object that indicates whether a certain value is ON or OFF. The display state of a check box is always either checked or unchecked. Although a check box is limited to two states, it is not limited to just two values. You specify the value to represent Checked, the value to represent Unchecked, and how other values are processed. You can use check boxes to enhance the user interface by converting existing items that have two possible states. Using a Check Box at Run Time You can do the following at run time: • Set check box values in the following ways: - By user input - By means of the Initial Value property - Programmatically • Query checked values. • Query unchecked values. • Ignore check box values in Enter Query mode by disabling the item with [Shift] + Click.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 8-7

Lesson 8: Creating Additional Input Items ......................................................................................................................................................

Creating a Check Box • • •

Convert an existing item. Use the Check Box tool in the Layout Editor. Use the Create icon in the Object Navigator.

Copyright  Oracle Corporation, 2000. All rights reserved.

Check Box Specific Properties • • • •

Data Type



Value When Unchecked



Check Box Mapping of Other Values



Mouse Navigate

Label Access Key Value When Checked

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 8-8 Oracle Forms Developer: Build Internet Applications I

Creating a Check Box ......................................................................................................................................................

Creating a Check Box A check box can be created in three ways: • Converting an existing item • Using the Check Box tool in the Layout Editor • Using the Create icon in the Object Navigator Item Properties Specific to the Check Box Property Data Type Label Access Key Initial Value Value When Checked Value When Unchecked Check Box Mapping of Other Values Mouse Navigate

Function Determines the data type (There is a restricted choice of CHAR, NUMBER, and DATE.) Specifies the text label that is displayed adjacent to the check box item (This is independent of the check box value.) Determines which combination of keys can be used to navigate to this item and check or uncheck it Specifies the initial value of the item and thus determines whether the check box is initially checked or unchecked Specifies a value to represent the checked state of the check box (The value must be compatible with the data type specified.) Specifies a value to represent the unchecked state of the check box (The value must be compatible with the data type specified.) Determines how other values are processed (Choose from NOT ALLOWED, CHECKED, and UNCHECKED.) Determines whether Form Builder navigates to the item and moves input focus to it when the user activates the item with the mouse (The default setting is Yes.)

Instructor Note The Mouse Navigate property applies only to GUI applications and is valid only for buttons, check boxes, list items, sound items, and radio group items. When Mouse Navigate is set to Yes, Form Builder navigates to the item, firing any appropriate navigation and validation triggers on the way.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 8-9

Lesson 8: Creating Additional Input Items ......................................................................................................................................................

Creating a Check Box

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Demonstration Using the ordwk07.fmb file, convert the Order_Filled item to a check box item. Point out that the object icon for this check box item changes automatically in the Object Navigator.

...................................................................................................................................................... 8-10 Oracle Forms Developer: Build Internet Applications I

Creating a Check Box ......................................................................................................................................................

How to Convert an Existing Item into a Check Box You can convert an existing item into a check box by changing the Item Type property to Check Box in the Property Palette and setting other relevant properties. 1 Invoke the Property Palette for the item that you want to convert. 2 Set the Item Type property to Check Box. 3 Enter a check box label. 4 Enter values for the checked and the unchecked states. 5 Set the Check Box Mapping of Other Values property. 6 Enter an initial value for the check box item. Note: The check box label that you specify is displayed to the right of the check box element at run time. If the complete label name is not displayed, adjust it in the Layout Editor. If the item already has a prompt, delete it in the item Property Palette. How to Create a Check Box in the Layout Editor You can also create a check box by using the Check Box tool in the Layout Editor. 1 Invoke the Layout Editor. 2 Set the canvas and block to those on which you want the check box item to be displayed. 3 Click the Check Box tool. 4 Click the canvas in the position where you want the check box to be displayed. 5 Double-click the check box to invoke its Property Palette. 6 Set the properties as required.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 8-11

Lesson 8: Creating Additional Input Items ......................................................................................................................................................

Check Box Mapping of Other Values

Order_Filled

Checked Y

Y Y

Unchecked

N

N

Null A

Check Box Mapping of Other Values Unchecked

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note You must specify a valid initial value, except under either of the following conditions: • The Check Box Mapping of Other Values property is set to Checked or Unchecked. • The value associated with Checked or Unchecked is NULL.

...................................................................................................................................................... 8-12 Oracle Forms Developer: Build Internet Applications I

Creating a Check Box ......................................................................................................................................................

Dealing with Other Values If your base table column accepts other values, then your check box should account for them. You can assign other values to either the checked or unchecked states by using the Check Box Mapping of Other Values property. Alternatively, you can choose not to accept other values with the Not Allowed setting. Note: If you choose not to accept other values and they exist in the base table column, Form Builder ignores the entire record during query processing. Dealing with Null Values If your base table column accepts null values, you can account for them by one of the following methods: • Set the Check Box Mapping of Other Values property. • Set the checked or unchecked state to represent null (leave the value blank). • Ignore a check box in Enter Query mode (use [Shift] + click).

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 8-13

Lesson 8: Creating Additional Input Items ......................................................................................................................................................

List Items •

Set of mutually exclusive choices, each representing a different value

• • •

Three list styles available Space-saving alternative to a radio group Smaller-scale alternative to an LOV

Copyright  Oracle Corporation, 2000. All rights reserved.

List Styles

Excellent

Poplist

Excellent Tlist Good Poor

Excellent

Combo Box

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 8-14 Oracle Forms Developer: Build Internet Applications I

Creating a List Item ......................................................................................................................................................

Creating a List Item What Is a List Item? A list item is an interface object that displays a predefined set of choices, each corresponding to a specific data value. You use the list item at run time to select a single value. List choices or elements are mutually exclusive; one and only one can be selected at a time. The Three List Item Styles List Style Poplist Tlist

Combo box

Description Appears as a field with an iconic button attached to the right side (When you click a poplist, all its list elements are displayed.) Appears as a rectangular box that displays the list elements (When the display area is not big enough to display all the list elements, a scroll bar is automatically attached to the right side to view the remaining list elements.) Appears as a field with a down arrow next to its right side (Use the button to display all the combo box list elements. The combo box accepts user input.)

Uses and Benefits of List Items • Enable display of a defined set of choices • Display a set of choices without using a vast area of canvas • Provide an alternative to radio groups • Provide a Windows-style list of values Setting the Value for a List Item The value for a list item can be set in any of the following ways: • User selection • User input (combo box style only) • A default value • Programmatic control

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 8-15

Lesson 8: Creating Additional Input Items ......................................................................................................................................................

Creating a List Item • • •

Convert an existing item. Use the List Item tool in the Layout Editor. Use the Create icon in the Object Navigator.

Copyright  Oracle Corporation, 2000. All rights reserved.

List Item Specific Properties •

Elements in List: – List elements – List item value

• • •

List Style Mapping of Other Values Mouse Navigate

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 8-16 Oracle Forms Developer: Build Internet Applications I

Creating a List Item ......................................................................................................................................................

Creating a List Item A list item can be created in three ways: • Converting an existing item • Using the List Item tool in the Layout Editor • Using the Create icon in the Object Navigator Item Properties Specific to the List Item Property Elements in List List Style Mapping of Other Values Mouse Navigate

Function Opens List Item Elements dialog window (covered later in this lesson) Specifies the display style of the list item (choose from Poplist, Tlist, or Combo Box) Determines how other values are processed Determines whether Form Builder navigates to the item and moves input focus to it when the user activates the item with the mouse

Note: The poplist and combo box take up less space, but end users must open them to see the list elements. A Tlist remains “open,” and end users can see multiple values at a time. Use the attached scroll bar to see more values if the Tlist is not big enough to display all the list elements. The Elements in List Property When you click the More property control button for the Elements in List property, the List Item Elements dialog window opens. Element

Description

List Elements

Enables you enter the list elements as they appear at run time

List Item Value

Enables you to specify the actual value that correspond to each of the list elements

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 8-17

Lesson 8: Creating Additional Input Items ......................................................................................................................................................

Creating a List Item

Copyright  Oracle Corporation, 2000. All rights reserved.

Technical Note To obtain a list of available functions when defining list elements, select [Ctrl] + k while the input focus is in the List Elements window. Instructor Note What are some of the differences between a list item and an LOV? List items: • Are generally used for a small number of elements • Do not have a Find button • Cannot be attached to other items • Are not based on a SELECT statement

...................................................................................................................................................... 8-18 Oracle Forms Developer: Build Internet Applications I

Creating a List Item ......................................................................................................................................................

How to Convert an Existing Item into a List Item You can convert an existing item into a list item by changing its Item Type property to List Item and setting the relevant properties. 1 Invoke the Property Palette for the item that you want to convert. 2 Set the Item Type property to List Item. 3 Select the Elements in List property. 4 Click More. The List Item Elements dialog box appears. 5 Enter the element that you want to appear in your list item in the List Elements column. 6 Enter the value for the currently selected list element in the List Item Value field. 7 Create additional list elements and values by repeating steps 5 and 6. 8 Click OK to accept and close the List Item Elements dialog box. 9 Set the Other Values property to do one of the following: - Reject values other than those predefined as list values - Accept and default all other values to one of the predefined list element values 10 Enter an initial value for the list item. How to Create a List Item in the Layout Editor You can also create a list item by using the List Item tool in the Layout Editor. 1 Invoke the Layout Editor. 2 Set the canvas and block to those on which you want the list item to be displayed. 3 Select the List Item tool. 4 Click the canvas in the position where you want the list item to be displayed. 5 Double-click the list item to invoke its Property Palette. 6 Set the properties as required.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 8-19

Lesson 8: Creating Additional Input Items ......................................................................................................................................................

List Item Mapping of Other Values

Credit_Rating

List Elements

EXCELLENT

Excellent

GOOD

Good

POOR

Poor

FAIR EXCELLENT Mapping of Other Values = Poor

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 8-20 Oracle Forms Developer: Build Internet Applications I

Creating a List Item ......................................................................................................................................................

NULL Values in a List Item If the base table column for a list item accepts NULL values, Form Builder creates a pseudochoice in the list to represent the null. All three list styles display a blank field if a query returns a NULL value. If the Data Required property is set to Yes, upon activation list items display a blank element. • A poplist displays a blank element for a NULL value. • For Tlists, the user must scroll through to display the blank element. • A combo box does not display a blank element. The end user must delete the default value if the default value is not NULL. Handling Other Values in a List Item If the base table column for a list item accepts values other than those associated with your list elements, you must specify how you want to handle the values. Do this in one of the following ways: • Ignore other values by leaving the Mapping of Other Values property blank. • Associate the other values with one of the existing list elements (by naming either the list element or its associated value) in the Mapping of Other Values property.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 8-21

Lesson 8: Creating Additional Input Items ......................................................................................................................................................

Radio Groups •

Set of mutually exclusive radio buttons, each representing a value



Use: – To display two or more static choices – As an alternative to a list item – As an alternative to a check box

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 8-22 Oracle Forms Developer: Build Internet Applications I

Creating a Radio Group ......................................................................................................................................................

Creating a Radio Group What Is a Radio Group? A radio group is a set of radio buttons. Each radio button represents a different value. These values and hence their corresponding radio buttons are mutually exclusive. Uses and Benefits of Radio Groups • Provide a choice between two or more static values • Provide an alternative to list items with two or three choices • Provide a choice between two alternatives, where choice is not On/Off or Yes/No; for example, Landscape or Portrait print format Note: Consider list items instead of radio groups if there are more than four or five choices. Using a Radio Group at Run Time You can do the following at run time: • Set radio group values: - By user input - By means of the Initial Value property - Programmatically • Query individual radio button values • Ignore radio button values in Enter Query mode by ensuring that none are selected

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 8-23

Lesson 8: Creating Additional Input Items ......................................................................................................................................................

Creating a Radio Group • • •

Convert an existing item. Create a new radio group item in the Layout Editor. Use the Create icon in the Object Navigator.

Copyright  Oracle Corporation, 2000. All rights reserved.

Radio Group and Radio Button Specific Properties Radio group

Radio button

• •

Data Type



• • •

Mouse Navigate

Mapping of Other Values

Access Key Label Radio Button Value

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 8-24 Oracle Forms Developer: Build Internet Applications I

Creating a Radio Group ......................................................................................................................................................

Creating a Radio Group A radio group can be created in three ways: • Converting an existing item to a radio group • Creating a new radio group item in the Layout Editor • Using the Create icon in the Object Navigator Item Properties Specific to Radio Group Items and Radio Buttons Radio Group Property Data Type Mapping of Other Values Mouse Navigate

Function Sets the data type (There is a restricted choice of CHAR, NUMBER, and DATE.) Determines how values other than those specified are processed Determines whether Form Builder navigates to the item when the operator activates the item with the mouse

Radio Button Property

Function

Name

Identifies each radio button in the radio group

Access Key

Determines which combination of keys can be used to navigate to and manipulate this button

Label

Specifies the text that appears adjacent to the radio button (These labels are independent of the button values.)

Radio Button Value

Specifies the value that the radio button represents in a radio group

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 8-25

Lesson 8: Creating Additional Input Items ......................................................................................................................................................

Creating Radio Buttons

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note The canvas property for a radio group is set in the Property Palette of the radio group. The individual radio buttons do not have a canvas property.

...................................................................................................................................................... 8-26 Oracle Forms Developer: Build Internet Applications I

Creating a Radio Group ......................................................................................................................................................

How to Convert an Existing Item into a Radio Group You can convert an existing item to a radio group by changing the item type and setting the properties for a radio group. 1 Invoke the Property Palette for the item that you want to convert. 2 Set the Item Type property to Radio Group. 3 Set the Mapping of Other Values property to specify how the Radio Group should handle any other values. 4 Set the Initial Value property, as required. This should be the name of a radio button. 5 Expand the item node in the Object Navigator. The Radio Buttons node appears. 6 Select the Radio Buttons node and click the Create icon. A radio button displays in the Object Navigator and the Property Palette takes on its context. 7 Enter a name, value, and a label for the radio button. 8 Specify the display properties of the radio button. 9 Create additional radio buttons by repeating steps 6 through 8. How to Create a Radio Group in the Layout Editor You can also create a radio group by using the Radio Button tool in the Layout Editor. 1 Invoke the Layout Editor. 2 Set the canvas and block to those on which you want the radio group to be displayed. 3 Select the Radio Button tool. 4 Position the cursor at the desired location and click. If you already have a radio group in the current block, the Radio Groups dialog box appears and you must decide whether the new radio button should appear in the existing group or a new one. 5 Double-click the radio button to invoke the Property Palette. The new radio group is created implicitly. 6 Set the radio button properties as required.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 8-27

Lesson 8: Creating Additional Input Items ......................................................................................................................................................

Radio Group Mapping of Other Values

Payment_Type

List Elements

CASH

BUTTON1 Cash

CHECK CREDIT Null

BUTTON2 Credit BUTTON3

Mapping of Other Values BUTTON1 Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note You must specify a valid initial value, except under either of the following conditions: • The radio group accepts other values. • The value associated with one of the radio buttons is NULL.

...................................................................................................................................................... 8-28 Oracle Forms Developer: Build Internet Applications I

Creating a Radio Group ......................................................................................................................................................

NULL Values in a Radio Group A radio group can treat NULL as a valid value. You should account for the NULL case, if your base table column allows them. Do this in one of the following ways: • Use the Mapping of Other Values property to implicitly force NULL to a radio button. • Assign the NULL to its own radio button. Note: To assign a NULL value to a radio button, leave the Radio Button Value property blank. Handling Other Values in a Radio Group If the base table column for a radio group accepts values other than those associated with your radio buttons, you must use one of the following methods to specify how you want to handle the values: • Ignore other values (by leaving the radio group’s Mapping of Other Values property blank) • Associate the other values with one of the existing radio buttons (by naming the associated value of the button in the Mapping of Other Values property) Note: Ignoring other values results in the entire row being ignored during query processing.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 8-29

Lesson 8: Creating Additional Input Items ......................................................................................................................................................

Summary • • •

Check boxes List items Radio groups

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 8-30 Oracle Forms Developer: Build Internet Applications I

Summary ......................................................................................................................................................

Summary In this lesson, you learned how to create items that accept direct user input. Use these items to enhance the user interface: • Check boxes: To convert items that have two possible states • List items (Poplists, Tlists, and Combo boxes): To convert items that are mutually exclusive • Radio groups: To convert items (two or three alternatives) that are mutually exclusive

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 8-31

Lesson 8: Creating Additional Input Items ......................................................................................................................................................

Practice 8 Overview

This practice covers the following topics:

• • • •

Converting a text item into a list item Converting a text item into a check box item Converting a text item into a radio group Adding radio buttons to the radio group

Copyright  Oracle Corporation, 2000. All rights reserved.

Note For solutions to this practice, see Practice 8 in Appendix A, “Practice Solutions.”

...................................................................................................................................................... 8-32 Oracle Forms Developer: Build Internet Applications I

Practice 8 Overview ......................................................................................................................................................

Practice 8 Overview In this practice session, you will convert existing text items into other input item types. You will create a list item, a check box, and a radio group. • In the CUSTOMERS form, convert the Credit_Rating item into a list item. Save and run the form. • In the ORDERS form, convert the Order_Filled item into a check box item. • In the ORDERS form, convert the Payment_Type item into a radio group. Add two radio buttons in the radio group. Save and run the form.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 8-33

Lesson 8: Creating Additional Input Items ......................................................................................................................................................

Practice 8 1 In the CUSTGXX form, convert the Credit_Rating text item into a pop-

2 3

4

5 6

up list item. Add list elements of Poor, Good, and Excellent to represent database values of POOR, GOOD, and EXCELLENT. Display any other values as POOR. Ensure that new records display the initial value GOOD. Resize the poplist in the Layout Editor, so that the elements do not truncate at run time. Save and compile the form. Deploy your form on the Web to test the changes. In the ORDGXX form, convert the Order_Filled text item into a check box. Set the checked state to represent the base table value of Y and the unchecked state to represent N. Ensure that new records are automatically assigned the value N. Allow only those records with Order_Filled values of Y or N to display. Remove the existing prompt and set label as Order Filled. In the Layout Editor, resize the check box so that its label is displayed to the right. Convert the Payment_Type text item into a radio group. Add radio buttons for Cash and Credit to represent database values of CASH and CREDIT. Define access keys of S for cash and T for credit. Add text Payment type to describe the radio group’s purpose. Set Label to Cash for Cash radio button and Credit for Credit radio button. Ensure that new records display the default of Cash. Reorder the items of the S_ORD block in the Object Navigator. Use the order of the items in the Layout Editor as a guide. Save, compile, and run the form to test the changes.

...................................................................................................................................................... 8-34 Oracle Forms Developer: Build Internet Applications I

9 ................................

Creating Noninput Items

Lesson 9: Creating Noninput Items ......................................................................................................................................................

Objectives

After completing this lesson, you should be able to do the following:

• • • • • • •

Identify item types that do not allow input Create a display item Create an image item Create a sound item Create a button Create a calculated item Create a hierarchical tree item

Copyright  Oracle Corporation, 2000. All rights reserved.

Schedule Topic Lecture Practice Total

Timing 60 minutes 40 minutes 100 minutes

...................................................................................................................................................... 9-2 Oracle Forms Developer: Build Internet Applications I

Introduction ......................................................................................................................................................

Introduction Overview Some Oracle Forms Developer item types do not accept user input (noninput items); however, they do provide an effective means of accessing data and initiating actions. This lesson describes how to create and use noninput items.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 9-3

Lesson 9: Creating Noninput Items ......................................................................................................................................................

Noninput Items

Item types that do not accept direct user input include:

• • • • • •

Display items Image items Sound items Buttons Calculated items Hierarchical tree items

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 9-4 Oracle Forms Developer: Build Internet Applications I

What Are Noninput Items? ......................................................................................................................................................

What Are Noninput Items? Noninput items is a generic term for item types that do not accept direct user input. However, you can set the value of some noninput items by programmatic control. Noninput items can be divided into two groups—those that can display data and those that cannot. Noninput Items That Can Display Data • Display items • Image items • Calculated items Noninput Items That Cannot Display Data • Sound items • Push Buttons Using Noninput Items Use noninput items to enhance your application by displaying additional data often from a nonbase table.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 9-5

Lesson 9: Creating Noninput Items ......................................................................................................................................................

Display Items • •

Display items are similar to text items. Display items cannot: – Be edited – Be queried – Be navigated to – Accept user input



Display items can: – Display data – Conserve resources

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 9-6 Oracle Forms Developer: Build Internet Applications I

Creating a Display Item ......................................................................................................................................................

Creating a Display Item What Is a Display Item? A display item is similar to a text item, except that it cannot be edited or navigated to at runtime. A display item is a read-only text box whose value must be fetched or assigned programmatically. Display items: • Display additional, no-base table information • Display derived data values • Conserve memory Note: Display items require less memory than text items. However, this is no longer as significant, now that we have the Rendered property for text items.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 9-7

Lesson 9: Creating Noninput Items ......................................................................................................................................................

Creating a Display Item

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 9-8 Oracle Forms Developer: Build Internet Applications I

Creating a Display Item ......................................................................................................................................................

Creating a Display Item A display item can be created by using: • The Layout Editor • The Create icon in the Object Navigator • The Item Type property to convert an existing item into a display item Whichever method you choose, you need to set the required item properties in the Property Palette. How to Create a Display Item from the Layout Editor 1 Invoke the Layout Editor. 2 Display the desired canvas and ensure that the correct data block is set. 3 Select the Display Item tool. 4 Click the canvas at the position where the display item is required. 5 Double-click the new display item. The Property Palette displays. 6 Change the name from DISPLAY_ITEMXX to the required name. 7 Specify the other properties as required. Note: Remember to set the Database Item property to No for a display item whose value is not stored in the base table. You can assign a format mask to a single-line display item by manipulating its Format Mask property.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 9-9

Lesson 9: Creating Noninput Items ......................................................................................................................................................

Image Items • •

Interface control Use to display bitmapped images: – From file system—supported file type – From database—LONG RAW column or a BLOB column

Copyright  Oracle Corporation, 2000. All rights reserved.

Technical Note You can also populate an image item with a BFILE, but you will need to use DBMS_LOB to do so.

...................................................................................................................................................... 9-10 Oracle Forms Developer: Build Internet Applications I

Creating an Image Item ......................................................................................................................................................

Creating an Image Item You can use images as graphic objects within a form module. A graphics image displays automatically and cannot be manipulated at run time. It can be imported from the database or the file system. Alternatively, you can display images within image items. What Is an Image Item? An image item is a special interface control that can store and display vector or scanned bitmapped images. Just as text items store and display VARCHAR2, number, or date values, image items store and display images. Like other items that store values, image items can be either data block items or control items. Displaying Image Items You can populate an image item by using one of the following methods: • Fetching from a LONG RAW or BLOB database column • Using a trigger and a built-in to populate the image item programmatically • Cutting or pasting an image to the clipboard, selecting the image item at runtime, and choosing Edit—>Paste Storing Images You can store images in either the database or the file system. When you insert images into the database by means of a Form Builder save (commit), they are automatically compressed using Oracle Image compression. Where Image Is Stored Description Database Long Raw column compressed image that can be up to four gigabytes File Any supported file format

Note: To conserve client memory when displaying large image items, reduce the number of records that are buffered by manipulating the Number of Records Buffered data block property.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 9-11

Lesson 9: Creating Noninput Items ......................................................................................................................................................

Image File Formats Image files

Image files

JPG

CALS

Image item

JPEG

CALS Read

TIFF

Write

GIF

GIF TIFF

JFIF

BMP BMP

JFIF

RAS

PICT

PICT

RAS

TPIC

TPIC Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 9-12 Oracle Forms Developer: Build Internet Applications I

Creating an Image Item ......................................................................................................................................................

Image File Formats Form Builder supports the following image formats: File Suffix BMP CALS GIF JFIF TIFF JPEG PICT RAS TPIC

Description Microsoft Windows and OS/2 BitMap Picture CALS type raster CompuServe JPEG File Interchange Format Tag Image File Format Joint Photographic Experts Group Macintosh Quickdraw Picture Sun Raster Truevision Raster Graphics Array Picture

Image Items Read/Write Read/Write Read/Write Read/Write Read/Write Read/Write Read/Write Read/Write Read /Write

Web Design Tip To reduce network traffic, limit the number of image items and background images in your Internet applications. Each time an image is required, it must be downloaded from the application server; images cannot be cached. For example, to display a company logo in your application, you could include the image in the HTML page that downloads at application startup rather than retrieving the image from the database or the file system. The HTML page can be cached.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 9-13

Lesson 9: Creating Noninput Items ......................................................................................................................................................

Image-Specific Item Properties • • • • • • • •

Image Format Image Depth Compression Quality Display Quality Show Palette Sizing Style Show Horizontal Scrollbar Show Vertical Scrollbar

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 9-14 Oracle Forms Developer: Build Internet Applications I

Creating an Image Item ......................................................................................................................................................

Item Properties Specific to the Image Item Property Image Format Image Depth

Compression Quality

Display Quality

Show Palette Sizing Style

Show Horizontal Scrollbar Show Vertical Scrollbar

Function Specifies the format in which the image item will be stored in the database Specifies the image depth setting for the image item being read from or written to a file in the file system (Choose from: Original, Monochrome, Gray, LUT, or RGB.) Specifies whether an image item being read from or written to a file should be compressed, and to what degree (Choose from: None, Minimum, Low, Medium, High, or Maximum.) Determines the resolution used to display the image item (You can use this property to control the trade off between quality and performance. Choose from: High, Medium, or Low.) Display image manipulation palette (Discussed later in this lesson). Determines how much of the image displays when the image size does not match the size of the item (Crop and Adjust are the two style choices. Crop cuts the edges off the images so that it fits in the rectangle. Adjust scales the image to fit within the display rectangle.) Displays a horizontal scroll bar Displays a vertical scroll bar

Note: Image items do not have a Data Type property. If you set an image item Database Item property to Yes, Form Builder understands that the data type is LONG RAW. Instructor Note • LUT = Lookup Table • RGB = Red, Green, Blue

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 9-15

Lesson 9: Creating Noninput Items ......................................................................................................................................................

Image Manipulation Palette Select Zoom Pan Rotate

Copyright  Oracle Corporation, 2000. All rights reserved.

Creating an Image Item

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 9-16 Oracle Forms Developer: Build Internet Applications I

Creating an Image Item ......................................................................................................................................................

Manipulating an Image To manipulate an image at run time, set the Show Palette property for the image item to Yes. This will display a palette adjacent to the image item with three image manipulation tools. Tool

Function

Select

Select an area in the image

Zoom

Zoom in or zoom out the image incrementally

Pan

Pan unseen portions of the image

Rotate

Rotate the image clockwise in 90-degree increments

Note: To zoom out, hold down the [Shift] key when you select the zoom tool. Creating an Image Item An image item can be created in three ways: • By using the Image Item tool in the Layout Editor (as described in the next section) • By using the Create icon in the Object Navigator • By converting an existing item into an image item Steps to Create an Image Item from the Layout Editor 1 Invoke the Layout Editor. 2 Set the canvas and block to those on which you require the item to display. 3 Select the Image Item tool. 4 Click the canvas at the position where you want the image item to display. 5 Double-click the image item. The Property Palette displays. 6 Change the name from IMAGEXX to the required name. 7 Specify the other properties as required. Note: Remember to set the Database Item property to No for an image item whose value is not stored in the base table.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 9-17

Lesson 9: Creating Noninput Items ......................................................................................................................................................

Sound Items • •

Interface control Use to play and record sound: – From file system—supported sound types – From database—LONG RAW column or BLOB column

Copyright  Oracle Corporation, 2000. All rights reserved.

Sound Item Control Slider

Play Record Rewind

Time Indicator

Fast Forward Volume

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 9-18 Oracle Forms Developer: Build Internet Applications I

Creating a Sound Item ......................................................................................................................................................

Creating a Sound Item What Is a Sound Item? A sound item is a special interface control that can play and record sound data. Sound data can be stored in either the database or a file system. Sound items can be either data block items or control items. Playing Sound Data You can play sound data in one of two ways: • Fetching from a LONG RAW or BLOB database column • Programmatically using a trigger and built-ins Sound Item Control When you create a sound item, Form Builder automatically represents the item in the layout with a sound control widget for user interaction. Each component within the sound control widget has a specific task. Sound Control

Description

Play

Starts playback of sound from the current pointer position

Record

Starts recording sound data from the current pointer position

Rewind

Rewinds sound data

Fast Forward

Fast forwards sound data

Volume

Displays a vertical slide control you can use to control playback and recording volume

Time Indicator

Displays three modes of time information for the sound data (You can click the indicator text to switch between total time, elapsed time, and remaining time.)

Slider

Displays a horizontal slide control to indicate current pointer position within the sound data (You can slide the handle left or right to reposition the pointer.)

Note: Each of the sound control components is optional, except for Play or Record, one of which must always be displayed if the sound item is visible.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 9-19

Lesson 9: Creating Noninput Items ......................................................................................................................................................

Sound Types AIFF

AIFF-C

AU

WAV

Copyright  Oracle Corporation, 2000. All rights reserved.

Sound-Specific Item Properties • • • • •

Sound Format Audio Channels Compress Sound Quality Show Play/Record/Rewind/Fast Forward/Volume Control/Time Indicator/Slider Button

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 9-20 Oracle Forms Developer: Build Internet Applications I

Creating a Sound Item ......................................................................................................................................................

Sound Types Form Builder supports the following sound types: • AU • AIFF • AIFF-C • WAV Creating a Sound Item A sound item can be created in three ways: • By converting an existing item • By using the Sound Item tool in the Layout Editor • By using the Create icon in the Object Navigator Item Properties Specific to the Sound Item Property

Function

Sound Format

Specifies the format in which the sound item will be stored in the database (Choose from AU, AIFF, AIFF-C, or WAVE.)

Audio Channels

Specifies the number of channels with which the sound item will be stored in the database (Choose from Automatic, Mono, or Stereo.)

Compress

Specifies whether a sound object that is read from a file should be compressed

Sound Quality

Specifies the quality for storing the sound item in the database (Choose from Automatic, Highest, High, Medium, Low, or Lowest.)

Show Play/Record/ Rewind/Fast Forward/ Volume Control/Time Indicator/Slider Button

To display or hide a sound item control component

Note: Large sound objects can degrade performance over a network. Improve performance by setting the Update Changed Columns Only property to Yes for the sound item block.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 9-21

Lesson 9: Creating Noninput Items ......................................................................................................................................................

Creating a Sound Item

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note The built-ins that are relevant to sound items are covered in a later lesson.

...................................................................................................................................................... 9-22 Oracle Forms Developer: Build Internet Applications I

Creating a Sound Item ......................................................................................................................................................

How to Create a Sound Item from the Layout Editor 1 Invoke the Layout Editor. 2 Set the canvas and block to those you require the item to display on. 3 Select the Sound Item tool. 4 Click the canvas at the position in which you want the sound item to display. 5 Double-click the sound item. The Property Palette displays. 6 Change the name from SOUND_ITEMXX to the required name. 7 Specify the other properties as required. Note: Remember to set the Database Item property to No for a sound item whose value is not stored in the base table. Web Design Tip Sound items are not supported in Forms deployed on the Web.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 9-23

Lesson 9: Creating Noninput Items ......................................................................................................................................................

Buttons • • • •

Interface control Cannot display/represent data Use to initiate an action Display as: – Text button – Iconic

Copyright  Oracle Corporation, 2000. All rights reserved.

Buttons •

Use buttons to: – Move input focus – Display an LOV – Invoke an editor – Invoke another window – Commit data – Issue a query – Perform calculations

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 9-24 Oracle Forms Developer: Build Internet Applications I

Creating a Push Button ......................................................................................................................................................

Creating a Push Button What Is a Push Button? A push button is an interface object that you click to initiate an action. A push button is usually displayed as a rectangle with a descriptive label inside. Push buttons cannot store or display values. You can enhance your form module further by adding push buttons to provide quick and direct access to the most needed operations. Push Button Styles Form Builder supports two push button styles: • Text button: Displayed with a text label on the push button • Iconic button: Displayed with a bitmapped graphic on the push button, and often used in toolbars Some Typical Push Button Actions • Moving the input focus • Displaying an LOV • Invoking an editor • Invoking another window • Committing data • Issuing a query • Performing calculations Note: Push buttons do not accept input focus on some window managers. On these platforms, the Keyboard Navigable property has no effect, and users can only interact with the items by using a mouse. Clicking a push button does not move the input focus on these platforms. The input focus remains in the item that was active before the push button.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 9-25

Lesson 9: Creating Noninput Items ......................................................................................................................................................

Button-Specific Item Properties • • • • • • •

Label Mouse Navigate Default Button Iconic Icon Filename Tooltip Tooltip Visual Attribute Group

Copyright  Oracle Corporation, 2000. All rights reserved.

Tool Tip

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 9-26 Oracle Forms Developer: Build Internet Applications I

Creating a Push Button ......................................................................................................................................................

Creating a Push Button A push button can be created by using: • The Push Button tool in the Layout Editor • The Create icon in the Object Navigator Item Properties Specific to the Push Button Property Label Mouse Navigate Default Button

Iconic Icon Filename Tooltip Tooltip Visual Attribute Group

Function Specifies the text label that appears on the push button at run time Determines whether Form Builder navigates to the item when you click on it by using the mouse Determines whether this is the default push button for the block (You can select the default push button implicitly by pressing a platformspecific key without the need to navigate or use the mouse.) Determines whether the push button displays as an icon instead of as a label Identifies the name of the file that contains the icon resource (Do not enter the icon file extension here.) Specifies the help text that should appear in a tool tip beneath the current item Specifies the named visual attribute that should be applied to the tool tip at run time

Note: On some window managers, the default push button is bordered or highlighted in a unique fashion to distinguish it from other push buttons. Tool Tip A tool tip is a small text box that displays help information about an item when you navigate to it with the mouse. The tool tip remains visible until the mouse is moved outside the item, or until another window is shown, or until the user performs an action in the current item. You can specify helpful information about a push button by entering the required help text in the Tooltip property of the push button. At run time, this text will automatically display in a small box when the user navigates to the push button. Instructor Note A tool tip is completely portable, and it replaces HINT.PLL/DLL. You cannot control the timing of a tool tip as you can with HINT.PLL by using timers. It is internalized in the form code.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 9-27

Lesson 9: Creating Noninput Items ......................................................................................................................................................

Creating a Button

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 9-28 Oracle Forms Developer: Build Internet Applications I

Creating a Push Button ......................................................................................................................................................

How to Create a Push Button from the Layout Editor 1 Invoke the Layout Editor. 2 Set the canvas and block to those on which you require the push button to display. 3 Select the Push Button tool. 4 Click the canvas at the position where you want the push button to display. 5 Double-click the push button. The Property Palette displays. 6 Change the name from PUSH_BUTTONXX to the required name. 7 Specify the other properties as required. Note: You can use the mouse to resize and move the push button once you have created it. Web Design Tip Icon image files for iconic buttons must be in GIF or JPEG format (and not in ICO format) if your form application is going to be deployed on the Web.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 9-29

Lesson 9: Creating Noninput Items ......................................................................................................................................................

Calculated Items •

They accept item values that are based on calculations.

• •

They are read-only. They can be expressed as: – Formula – Summary

Copyright  Oracle Corporation, 2000. All rights reserved.

Calculation Modes •

Formula – A calculated item value is the result of a horizontal calculation. – It involves bind variables.



Summary – A calculated item value is a vertical calculation. – A summary is performed on values of a single item over all rows in a block.

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 9-30 Oracle Forms Developer: Build Internet Applications I

Creating a Calculated Item ......................................................................................................................................................

Creating a Calculated Item What Is a Calculated Item? With a calculated item you can declaratively base item values on calculations involving one or more variable values. For example, obtaining a running total of employees’ total compensation. Any item that can store a value can be used as a calculated item by setting its required property values. Calculation Modes Calculations can be expressed as a formula or as a summary of all items in a block. Form Builder supports the following calculation modes: Calculation Mode

Description

Formula

The calculated item value is the result of a horizontal calculation involving one or more bind variables, such as form items, global variables, and parameters

Summary

The calculated item value is a vertical calculation involving the values of a single item over all the rows within a single block

Note: A calculated item is read only. End users cannot insert or modify calculate items. You should, therefore, generally use display items as calculated items. Instructor Note Point out to the students that, unlike the rest of the items covered so far in this lesson, there is no Item Type property value called Calculated Item. The calculation-specific properties of an item make it a calculated item. Both text as well as display items support calculated items.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 9-31

Lesson 9: Creating Noninput Items ......................................................................................................................................................

Item Properties Specific to the Calculated Item Formula

Summary

• •

• • • •

Calculation Mode Formula

Calculation Mode Summary Function Summarized Block Summarized Item

Copyright  Oracle Corporation, 2000. All rights reserved.

Summary Functions • • • • • • •

AVG COUNT MAX MIN STDDEV SUM VARIANCE

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 9-32 Oracle Forms Developer: Build Internet Applications I

Creating a Calculated Item ......................................................................................................................................................

Creating a Calculated Item A calculated item can be created by: • Setting the calculation specific properties of any existing item that can store a value • Creating a new item in the Layout Editor and setting its calculation specific properties • Using the Create icon in the Object Navigator and setting its calculation specific properties Item Properties Specific to the Calculated Item Property

Function

Calculation Mode

Specifies the method of computing the calculated item value (Choose from None, Formula, and Summary.)

Formula

Specifies a single PL/SQL expression that determines the calculated item value (The expression can compute a value or call a subprogram.)

Summary Function

Specifies the type of summary function to be performed on the calculated item (discussed later in this lesson).

Summarized Block

Specifies the block over which all rows will be summarized in order to assign a value to the calculated item; required if the item Calculation Mode property value is set to Summary

Summarized Item

Specifies the item whose value is summarized in order to be assign a value to the calculated item; required if the item Calculation Mode property value is set to Summary

Summary Functions You can use the standard SQL aggregate functions for summary items: • AVG • COUNT • MAX • MIN • STDDEV • SUM • VARIANCE

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 9-33

Lesson 9: Creating Noninput Items ......................................................................................................................................................

Item Based on a Formula Order

ORDERS

NVL((:s_item.price * :s_item.quantity_shipped),0) Item Item Item id Product id Price Qty Shipped Total 200 1,000 1 5 2 120 480 4 50 3 9 450 25 4 75 3

Formula item

Copyright  Oracle Corporation, 2000. All rights reserved.

Rules for Formula Items • •

A formula item must not invoke restricted built-ins.



Do not terminate a PL/SQL expression with a semicolon.



Do not enter a complete PL/SQL statement in assignment expressions.

A formula item cannot execute any DML statements.

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 9-34 Oracle Forms Developer: Build Internet Applications I

Creating a Calculated Item ......................................................................................................................................................

How to Create an Item Based on a Formula 1 Create a new item in the Object Navigator. 2 Open the Property Palette of the item. 3 Set the Calculation Mode property to Formula. 4 Click More for the Formula property and enter the PL/SQL expression to define the formula. Note: A formula item cannot be a database item because its value is computed by Form Builder, not queried from a database column. Rules for Creating an Item Based on a Formula • The formula (and any user-written subprogram that calls it) must not invoke any restricted built-ins. • The formula (and any user-written subprogram that calls it) cannot execute any DML statements. • Do not terminate the PL/SQL expression with a semicolon. • If the PL/SQL expression involves an assignment, do not enter the complete PL/SQL statement. Form Builder assigns the actual assignment code internally. Example If you set the Formula property to: NVL(:s_emp.salary,0) * NVL(:s_emp.commission_pct,0)

Form Builder will internally convert this expression into a complete statement as: :s_emp.gross_comp := (NVL(:s_emp.salary,0) * NVL(:s_emp.commission_pct,0));

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 9-35

Lesson 9: Creating Noninput Items ......................................................................................................................................................

Item Based on a Summary Order

ORDERS

Summarized item Item Item Item id Product id Price Qty Shipped Total 1 200 1,000 5 2 120 480 4 50 3 9 450 25 4 3 75 Order Total 2,005

Summary item

Copyright  Oracle Corporation, 2000. All rights reserved.

Rules for Summary Items •

Summary item must reside in: – The same block as the summarized item – A control block with Single Record property set to Yes



Summarized item must reside in: – A data block with Query All Records property or Precompute Summaries property set to Yes – A control block



Datatype of summary item must be Number, unless using MAX or MIN Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 9-36 Oracle Forms Developer: Build Internet Applications I

Creating a Calculated Item ......................................................................................................................................................

How to Create an Item Based on a Summary 1 Create a new item in the Object Navigator. 2 Open the Property Palette of an item. 3 Set the Calculation Mode property to Summary. 4 Select the required function from the Summary Function pop-up list. 5 From the Summarized Block pop-up list, select a block over which all rows will be summarized. 6 From the Summarized Item pop-up list, select an item to be summarized. Note: A summary item is the calculated item to which you assign a value. A summarized item is the item whose values are summarized and then assigned to the summary item. Rules for Creating an Item Based on a Summary • The summary item must reside in the same block as the summarized item, or in a control block whose Single Record property is set to Yes. • The summarized item must reside in a control block, or in a data block whose Query All Records property or the Precompute Summaries property is set to Yes. Note: This ensures that records fetched in the block and the summarized value are consistent. Otherwise, another user may possibly update a record that has not been fetched yet. • Set the Data Type property for a summary item to Number, unless the summary function is Max or Min, in which case the datatype must mirror that of its associated summarized item. • If the summarized item values are based on a formula, the summarized item must reside in a block whose Query All Records property is set to Yes.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 9-37

Lesson 9: Creating Noninput Items ......................................................................................................................................................

Creating a Hierarchical Tree

Copyright  Oracle Corporation, 2000. All rights reserved.

Hierarchical Tree Properties • • • • • •

Allow empty branches Multi selection Show lines Show symbols Record group Data query

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 9-38 Oracle Forms Developer: Build Internet Applications I

Creating a Hierarchical Tree Item ......................................................................................................................................................

Creating a Hierarchical Tree Item A hierarchical tree is an item that displays data in the form of a standard navigator. How to Create a Hierarchical Tree Item To create a hierarchical tree item, do one of the following: • In the Layout Editor: - Click the Hierarchical Tree icon. - Click and drag the mouse on the canvas to create the hierarchical tree object. - Set other hierarchical tree-related properties as required. • In the Object Navigator: - Create a new item by using the Create icon. - Open the item’s Property Palette and set the Item Type property to Hierarchical Tree. - Set other hierarchical tree related properties as required. Hierarchical Tree Properties Hierarchical Tree Properties include: • Item Type • Allow Empty Branches • Multi Selection • Show Lines • Show Symbols • Record Group • Data Query Several new built-ins are available to manipulate hierarchical trees. These are discussed in Lesson 15. Note: A hierarchical tree must be the only item in the data block. Instructor Note Lesson 15 discusses how to implement a hierarchical tree in a form.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 9-39

Lesson 9: Creating Noninput Items ......................................................................................................................................................

Summary • • • • • •

Display items Image items Sound items Buttons Calculated items Hierarchical tree items

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 9-40 Oracle Forms Developer: Build Internet Applications I

Summary ......................................................................................................................................................

Summary In this lesson, you should have learned that: • Display items display graphics or conditional text. • Image items store and display vector or scanned bitmapped images. • Sound items play and record sound data. • Push Buttons initiate an action. • Calculated items base item values on calculations. Calculations can be expressed in one of the following modes: - Formula - Summary • Hierarchical trees display information in an Object Navigator style display.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 9-41

Lesson 9: Creating Noninput Items ......................................................................................................................................................

Copyright  Oracle Corporation, 2000. All rights reserved.

Note For solutions to this practice, see Practice 9 in Appendix A, “Practice Solutions.”

...................................................................................................................................................... 9-42 Oracle Forms Developer: Build Internet Applications I

Practice 9 Overview ......................................................................................................................................................

Practice 9 Overview In this practice session, you will add several items in the CUSTOMERS and ORDERS forms: display items, image item, push buttons, and calculated items. • In the ORDERS form, create two display items in the S_ITEM block. • Create an image item in the S_ITEM block. • In the ORDERS form, create an iconic button in the control block. • In the ORDERS form, base the Item_Total item in the S_ITEM block on a formula. Create a control item in the same block. Base this item value on a summary that displays the total value of an order. • In the CUSTOMERS form, create an iconic button in the CONTROL block. • Save and run the ORDERS and CUSTOMERS forms.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 9-43

Lesson 9: Creating Noninput Items ......................................................................................................................................................

Practice 9 1 In the S_ITEM block of the ORDGXX form, create a display item called

2 3

4

5

6

Description. Set the Prompt property to Description and display the prompt above the item. Create a single-record image item called Product_Image in the S_ITEM block of the ORDGXX form. Create another display item, Image_Description, in the S_ITEM block. This should synchronize with the Description item. Set the Maximum Length property to the same value as the Description item. In the CONTROL block of the ORDGXX form, create an iconic button called Product_LOV_Button. Use the list file (do not include the .ico or .gif extension). Set both the Keyboard Navigable property and the Mouse Navigate property to No. To display item total information, set the following properties for the Item_Total item in the S_ITEM block: - Set the Justification property to right. - Set the Calculation Mode property to Formula. - Set the Formula property to :S_ITEM.quantity_shipped * :S_ITEM.price. - Set the Keyboard Navigable property to No. To display the total of the item totals create a new nondatabase item in the S_ITEM block. - Set the position, size and prompt properties according to the screenshot. - Set the format mask property to 9G999G990D99. - Set the Justification property to right. - Set the Number of Items Displayed property to 1. - Make S_ITEM.total a summary item and display summaries of the item_total values in the S_ITEM block. Ensure that you have to set the Query All Records property to Yes for the S_ITEM block. - Set the Keyboard Navigable property to No.

...................................................................................................................................................... 9-44 Oracle Forms Developer: Build Internet Applications I

Practice 9 ......................................................................................................................................................

7 Save, compile, and run the forms to test the changes. Change the

window size if necessary.

8 Perform a query in the ORDGXX form to ensure that the new items do

not cause an error. Did you remember to switch off the Database Item property for items that do not correspond to columns in the base table? 9 Create an iconic button similar to the one created in question 4, in the CONTROL block of form CUSTGXX. Use the list file (do not include the .ico or .gif extension). Name the push button Sales_Rep_Lov_Button, and place it next to Sales_Rep_ID. 10 Save and compile the form. Deploy the form on the Web to test the changes. Note: When you test the form on the Web, the iconic button will have a different image than the same iconic button in the client-server environment. This is because the image stored in list.gif is different from the image stored in list.ico. ...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 9-45

Lesson 9: Creating Noninput Items ......................................................................................................................................................

...................................................................................................................................................... 9-46 Oracle Forms Developer: Build Internet Applications I

10 ................................

Creating Windows and Content Canvases

Lesson 10: and Content Canvases ......................................................................................................................................................

Objectives

After completing this lesson, you should be able to do the following:

• •

Describe windows and content canvases Describe the relationship between windows and content canvases

Copyright  Oracle Corporation, 2000. All rights reserved.

Objectives • • •

Identify window and content canvas properties Display a form module in multiple windows Display a form module on multiple layouts

Copyright  Oracle Corporation, 2000. All rights reserved.

Schedule Topic Lecture Practice Total

Timing 30 minutes 20 minutes 50 minutes

...................................................................................................................................................... 10-2 Oracle Forms Developer: Build Internet Applications I

Introduction ......................................................................................................................................................

Introduction Overview With Oracle Forms Developer you can take advantage of the GUI environment by displaying a form module across several canvases and in multiple windows. This lesson familiarizes you with the window object and the default canvas type, the content canvas.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 10-3

Lesson 10: and Content Canvases ......................................................................................................................................................

Windows and Canvases •

Window: Container for Form Builder visual objects



Canvas: Surface on which you “paint” visual objects To see a canvas and its objects, display the canvas in a window.

Copyright  Oracle Corporation, 2000. All rights reserved.

Window, Canvas, and Viewport MDI parent window Document window

Canvas

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note You can demonstrate ownership and visual view at this point.

...................................................................................................................................................... 10-4 Oracle Forms Developer: Build Internet Applications I

Windows and Content Canvases ......................................................................................................................................................

Windows and Content Canvases With Form Builder you can display an application in multiple windows by using its display objects—windows and canvases. What Is a Window? A window is a container for all visual objects that make up a Form Builder application. It is similar to an empty picture frame. The window manager provides the controls for the window that enable such functionality as scrolling, moving, and resizing. You can minimize a window. A single form may include several windows. What Is a Canvas? A canvas is a surface inside a window container on which you place visual objects such as interface items and graphics. It is similar to the canvas upon which a picture is painted. To see a canvas and its contents at run time, you must display it in a window. A canvas always displays in the window to which it is assigned. Note: Each item in a form must refer to no more than one canvas. An item displays on the canvas to which it is assigned, through its Canvas property. Recall that if the Canvas property for an item is left unspecified, that item is said to be a Null-canvas item and will not display at runtime. What Is a Viewport? A viewport is an attribute of a canvas. It is effectively the visible portion of, or view onto, the canvas.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 10-5

Lesson 10: and Content Canvases ......................................................................................................................................................

Content Canvas • • • •

“Base” canvas View occupies entire window Default canvas type Each window should have at least one content canvas

Copyright  Oracle Corporation, 2000. All rights reserved.

Windows and Content Canvases Canvas 1

Window Canvas 2

Canvas 3

Copyright  Oracle Corporation, 2000. All rights reserved.

Note At run time, only one content canvas can display in a window at a time. However, you can assign multiple content canvases to a window.

...................................................................................................................................................... 10-6 Oracle Forms Developer: Build Internet Applications I

Windows and Content Canvases ......................................................................................................................................................

What Is a Content Canvas? Form Builder offers different types of canvases. A content canvas is the base canvas that occupies the entire content pane of the window in which it displays. The content canvas is the default canvas type. Most canvases are content canvases. The Relationship Between Windows and Content Canvases You must create at least one content canvas for each window in your application. When you run a form, only one content canvas can display in a window at a time, even though more than one content canvas can be assigned to the same window at design time. At run time, a content canvas always completely fills its window. As the user resizes the window, Form Builder resizes the canvas automatically. If the window is too small to show all items on the canvas, Form Builder automatically scrolls the canvas to bring the current item into view. Instructor Note Point out to the students that the rest of the canvas types will be covered in the next lesson.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 10-7

Lesson 10: and Content Canvases ......................................................................................................................................................

Windows •

WINDOW1: – It is created by default with each new form module. – It is modeless. – You can delete, rename, or change its attributes.

Copyright  Oracle Corporation, 2000. All rights reserved.

Windows •

Use additional windows to: – Display two or more content canvases at once – Modularize form contents – Switch between canvases without replacing the initial one – Take advantage of the window manager



Two types of windows: – Modal – Modeless

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 10-8 Oracle Forms Developer: Build Internet Applications I

Displaying a Form Module in Multiple Windows ......................................................................................................................................................

Displaying a Form Module in Multiple Windows When you create a new form module, Form Builder creates a new window implicitly. Thus, each new form module has one predefined window, which is called WINDOW1. You can delete or rename WINDOW1, or change its attributes. Uses and Benefits of a New Window You can create additional windows in which to display your form application. A new or second window provides the ability to do the following: • Display two or more content canvases at once. • Modularize the form contents. • Switch between canvases without replacing the initial one. • Take advantage of window manager functionality such as minimizing. Window Types You can create two different window types: modal and modeless. • A modal window is a restricted window that the user must respond to before moving the input focus to another window. Modal windows: - Must be dismissed before control can be returned to a modeless window - Become active as soon as they display - Require a means of exit or dismissal • A modeless window is an unrestricted window that the user can exit freely. Modeless windows: - Can display many at once - Are not necessarily active when displayed - Are the default window type

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 10-9

Lesson 10: and Content Canvases ......................................................................................................................................................

Window Properties

3 1 2

4

5 6 7

Copyright  Oracle Corporation, 2000. All rights reserved.

1

MDI parent window

2

X/Y position

3

Title

4

Document window

5

Dialog window

6

Show vertical scroll bar

7

Show horizontal scroll bar

...................................................................................................................................................... 10-10 Oracle Forms Developer: Build Internet Applications I

Displaying a Form Module in Multiple Windows ......................................................................................................................................................

Window Properties Physical Property X Position Y Position Width Height Bevel Show Horizontal Scrollbar Show Vertical Scrollbar Functional Property Title Primary Canvas Window Style

Modal Hide on Exit Icon Filename

Function Determines the X coordinate for the window Determines the Y coordinate for the window Determines the width of the window Determines the height of the window Determines how the window border displays Determines whether a horizontal scroll bar displays in the window Determines whether a vertical scroll bar displays in the window Function Specifies a window title to appear in the title bar Specifies the name of the canvas to display in this window when it is invoked programmatically Determines whether the window style is Document or Dialog (Document style windows are fixed and always remain within the application window frame. Dialog style windows are free floating and can be moved outside the application window frame.) Determines whether the window is modal (requires user response) or modeless (does not require user response) Specifies whether a modeless window is hidden automatically when the end user navigates to an item in another window Specifies the icon resource name that depicts the minimized window

Note: If you do not specify a window title, Form Builder uses the window object name specified in the Name property for the title. The canvas you choose as the primary canvas must be a content canvas. The X and Y Position (0,0) of a window is relative to the top left corner of the screen when you set the Window Style to dialog. If you set the Window Style to document, the X and Y Position (0,0) is relative to the top-left corner of the MDI window.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 10-11

Lesson 10: and Content Canvases ......................................................................................................................................................

GUI Hints •

GUI hints are recommendations to the window manager about window appearance and functionality.



If the window manager supports a specific GUI Hint and its property is set to Yes, it will be used.



Functional properties for GUI Hints: - Close Allowed

- Maximize Allowed

- Move Allowed

- Minimize Allowed

- Resize Allowed

- Inherit Menu

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note The Resize Allowed property can be set to prevent an end user from resizing the window, but it does not prevent you from resizing the window programmatically. Demonstration Using the ordwk09.fmb file, create a new window in the Orders form. Show that the new window does not display at run time. Explain that the new window will not display until it is specified in the Window property of a canvas.

...................................................................................................................................................... 10-12 Oracle Forms Developer: Build Internet Applications I

Displaying a Form Module in Multiple Windows ......................................................................................................................................................

What Are GUI Hints? GUI Hints are recommendations to the window manager about the window appearance and functionality. There are certain properties under the Functional group that enable you to make these recommendations. If the current window manager supports the specific GUI Hint property and it is set to Yes, then Form Builder uses it. However if the window manager does not support the property, Form Builder ignores it. Functional Property for GUI Hints Close Allowed

Move Allowed Resize Allowed Maximize Allowed Minimize Allowed Inherit Menu

Function Enables the mechanism for closing the window, as provided by the window manager-specific Close command (Form Builder responds to user attempts to close the window by firing a WHEN-WINDOW-CLOSED trigger to actually close it.) Determines whether the user can move the window by using the means provided by the window manager Determines whether the user can resize the window at run time Determines whether the user can resize the window by using the zooming capabilities of the window manager Determines whether the user can iconify and minimize the window Determines whether the window displays the current form menu

Note: The Minimize Allowed property must be set to Yes in order for Icon Filename to be valid. How to Create a New Window 1 Click the Windows node in the Object Navigator. 2 Click the Create icon. A new window entry displays, with a default name of WINDOWXX. 3 If the Property Palette is not already displayed, double-click the window icon to the left of the new window entry. 4 Set the window properties according to your requirements (as described in the tables, earlier in this lesson). Note: For your new window to display, you must specify its name in the Window property of at least one canvas. Web Design Tip To display a console to end users, set the form-level property Console Window to the window in which you want to display the console.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 10-13

Lesson 10: and Content Canvases ......................................................................................................................................................

Creating a Content Canvas •

Implicitly: – Using the Layout Wizard – Using the Layout Editor



Explicitly: Using the Create icon in the Object Navigator

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 10-14 Oracle Forms Developer: Build Internet Applications I

Displaying a Form Module on Multiple Layouts ......................................................................................................................................................

Displaying a Form Module on Multiple Layouts You can have more than one content canvas in your form application. However, remember that only one content canvas can display in a window at one time. To display more than one content canvas at the same time, you can assign each content canvas to a different window. Now you can display the form module on multiple layouts or surfaces. Creating a New Content Canvas Implicitly There are two ways of implicitly creating a new content canvas: • Layout Wizard: When you use the Layout Wizard to arrange data block items on a canvas, the wizard enables you to select a new canvas on its Canvas page. In this case, the wizard creates a new canvas with a default name of CANVASXX. • Layout Editor: When there are no canvases in a form module and you invoke the Layout Editor; Form Builder creates a default canvas on which you can place items. Creating a New Content Canvas Explicitly You can create a new content canvas explicitly by using the Create icon in the Object Navigator.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 10-15

Lesson 10: and Content Canvases ......................................................................................................................................................

Content Canvas Properties Viewport

Viewport X/Y Position on canvas

Height

Canvas Width Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Demonstration Display the contents of the S_INVENTORY data block in the new window created in the previous demonstration. Also, since Release 6, the Show View option in the View menu of the Layout Editor displays the size of the window for a content canvas.

...................................................................................................................................................... 10-16 Oracle Forms Developer: Build Internet Applications I

Displaying a Form Module on Multiple Layouts ......................................................................................................................................................

Content Canvas Specific Properties General Property

Function

Canvas Type

Specifies the type of canvas (For a content canvas, this property should be set to Content.)

Physical Property Window Viewport X Position on Canvas Viewport Y Position on Canvas Width Height Bevel

Function Specifies the window in which the canvas will be displayed Specifies the X coordinate of the top-left corner of the view relative to the upper-left corner of the canvas Specifies the Y coordinate of the top-left corner of the view relative to the upper-left corner of the canvas Specifies the width of the canvas Specifies the height of the canvas Specifies a sculpted effect canvas border

Functional Property Raise on Entry

Function Determines whether the canvas is always brought to the front of the window when the user navigates to an item on this canvas (Use this property when the canvas is displayed in the same window with other types of canvases.)

Note: For a canvas to display at run time, its Window property must be specified. How to Create a New Content Canvas 1 Click the Canvases node in the Object Navigator. 2 Click the Create icon. A new canvas entry displays with a default name of CANVASXX. 3 If the Property Palette is not already displayed, click the new canvas entry and select Tools—>Property Palette. 4 Set the canvas properties that are described in the above tables according to your requirements. Note: Double-clicking the icon for a canvas in the Object Navigator will invoke the Layout Editor instead of the Property Palette.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 10-17

Lesson 10: and Content Canvases ......................................................................................................................................................

Summary • • •

Describing windows and content canvases Creating a new window Creating a new content canvas

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 10-18 Oracle Forms Developer: Build Internet Applications I

Summary ......................................................................................................................................................

Summary In this lesson, you should have learned: • About the relationship between windows and content canvases • How to create a new window • How to create a new content canvas

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 10-19

Lesson 10: and Content Canvases ......................................................................................................................................................

Practice 10 Overview

This practice covers the following topics:

• • •

Changing a window size, position, name, and title Creating a new window Displaying data block contents in the new window

Copyright  Oracle Corporation, 2000. All rights reserved.

Note For solutions to this practice, see Practice 10 in Appendix A, “Practice Solutions.”

...................................................................................................................................................... 10-20 Oracle Forms Developer: Build Internet Applications I

Practice 10 Overview ......................................................................................................................................................

Practice 10 Overview In this practice session, you will customize windows in your form modules. You will resize the windows to make them more suitable for presenting canvas contents. You will also create a new window to display the contents of the S_INVENTORY block. • Change the size and position of the window in the CUSTOMERS form. Change its name and title. Save and run the form. • Modify the name and title of the window in the ORDERS form. • Create a new window in the ORDERS form. Make sure the contents of the S_INVENTORY block display in this window. Save and run the form.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 10-21

Lesson 10: and Content Canvases ......................................................................................................................................................

Practice 10 1 Modify the window in the CUSTGXX form. Change the name of the

2 3 4

5

6

window to WIN_CUSTOMER, and change its title to Customer Information. Check that the size and position are suitable. Save, compile, and run the form to test the changes. Modify the window in the ORDGXX form. Ensure that the window is called WIN_ORDER. Also change its title to Orders and Items. In the ORDGXX form, create a new window called WIN_INVENTORY suitable for displaying the CV_INVENTORY canvas. Use the rulers in the Layout Editor to help you plan the height and width of the window. Set the window title to Stock Levels and the Hide on Exit property to Yes. Place the new window in a suitable position relative to WIN_ORDER. Associate the CV_INVENTORY canvas with the window WIN_INVENTORY. Compile the form. Deploy the form on the Web and ensure that the S_INVENTORY block displays in WIN_INVENTORY when you navigate to this block. Save the form.

...................................................................................................................................................... 10-22 Oracle Forms Developer: Build Internet Applications I

11 ................................

Working with Other Canvases

Lesson 11: Working with Other Canvases ......................................................................................................................................................

Objectives

After completing this lesson, you should be able to do the following:



Describe the different types of canvases and their relationships to each other



Identify the appropriate canvas type for different scenarios



Create an overlay effect by using stacked canvases

• •

Create a toolbar Create a tabbed interface

Copyright  Oracle Corporation, 2000. All rights reserved.

Schedule Topic Lecture Practice Total

Timing 60 minutes 40 minutes 100 minutes

...................................................................................................................................................... 11-2 Oracle Forms Developer: Build Internet Applications I

Introduction ......................................................................................................................................................

Introduction Overview In addition to the content canvas, Oracle Forms Developer enables you to create three other canvas types. This lesson introduces you to the stacked canvas, which is ideal for creating overlays in your application. It also introduces you to the toolbar canvas and the tabbed canvas, both of which enable you to provide a user-friendly GUI application.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 11-3

Lesson 11: Working with Other Canvases ......................................................................................................................................................

Canvas Types Content canvas

Horizontal toolbar

Vertical toolbar

Stacked canvas Tab

x

y

z

Tab page

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Demonstration Open the win_demo.fmb form and run it. In the run-time session, move the yellow and purple windows around. In the gray window, point out the gray content canvas and the green toolbar. Scroll the blue and red stacked canvases using the scrollbars. Switch between the different windows by using the mouse. Point out the MDI parent window.

...................................................................................................................................................... 11-4 Oracle Forms Developer: Build Internet Applications I

Canvases Overview ......................................................................................................................................................

Canvases Overview Besides the content canvas, Form Builder provides three other types of canvases which are: • Stacked canvas • Toolbar canvas • Tab canvas When you create a canvas, you specify its type by setting the Canvas Type property. The type determines how the canvas is displayed in the window to which it is assigned.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 11-5

Lesson 11: Working with Other Canvases ......................................................................................................................................................

Stacked Canvas • • •

Displayed on top of a content canvas Shares a window with a content canvas Size: – Usually smaller than the content canvas in the same window – Determined by viewport size



Created in: – Object Navigator – Layout Editor

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 11-6 Oracle Forms Developer: Build Internet Applications I

Creating a Stacked Canvas ......................................................................................................................................................

Creating a Stacked Canvas What Is a Stacked Canvas? A stacked canvas is displayed on top of, or stacked on, the content canvas assigned to a window. It shares a window with a content canvas and any number of other stacked canvases. Stacked canvases are usually smaller than the window in which they display. Determining the Size of a Stacked Canvas Stacked canvases are typically smaller than the content canvas in the same window. Determine the stacked canvas dimensions by setting Width and Height properties. Determine the stacked canvas view dimensions by setting Viewport Width and Viewport Height properties. Uses and Benefits of Stacked Canvases • Scrolling views as generated by Oracle Designer • Creating an overlay effect within a single window • Displaying headers that display constant information, such as company name • Creating a cascading or a revealing effect within a single window • Displaying additional information • Displaying information conditionally • Displaying context-sensitive help • Hiding information Note: If a data block contains more items than the window can display, Form Builder scrolls the window to display items outside the window frame. This can cause important items, such as primary key values, to scroll out of view. By placing important items on a content canvas, and placing the items that can be scrolled out of sight on a stacked canvas, the stacked canvas becomes the scrolling region, rather than the window itself. Creating a Stacked Canvas You can create a stacked canvas in either of the following: • Object Navigator • Layout Editor

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 11-7

Lesson 11: Working with Other Canvases ......................................................................................................................................................

Stacked Canvas Properties

2

1 3 4

5 Copyright  Oracle Corporation, 2000. All rights reserved.

1

Content canvas

2

Stacked canvas

3

Viewport X/Y position

4

Viewport height

5

Viewport width

...................................................................................................................................................... 11-8 Oracle Forms Developer: Build Internet Applications I

Creating a Stacked Canvas ......................................................................................................................................................

Stacked Canvas Specific Properties Viewport Property Viewport X Position Viewport Y Position Viewport Width Viewport Height

Function Specifies the X coordinate of the stacked canvas viewport Specifies the Y coordinate of the stacked canvas viewport Specifies the width of the stacked canvas viewport Specifies the height of the stacked canvas viewport

Physical Property

Function

Show Horizontal Scrollbar

Determines whether the stacked canvas displays a horizontal scroll bar

Show Vertical Scrollbar

Determines whether the stacked canvas displays a vertical scroll bar

How to Create a Stacked Canvas in the Object Navigator 1 Click the Canvases node in the Object Navigator. 2 Click the Create icon. A new canvas entry displays with a default name of CANVASXX. 3 If the Property Palette is not already displayed, click the new canvas entry and select Tools—>Property Palette. 4 Set the Canvas Type property to Stacked. Additionally, set the properties that are described in the above table according to your requirements. Note: To convert an existing content canvas to a stacked canvas, change its Canvas Type property value from Content to Stacked. In order for the stacked canvas to display properly, make sure that its position in the stacking order places it in front of the content canvas assigned to the same window. The stacking order of canvases is defined by the sequence in which they appear in the Object Navigator.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 11-9

Lesson 11: Working with Other Canvases ......................................................................................................................................................

Creating a Stacked Canvas

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Demonstration Create a stacked canvas. Show the stacked canvas in the Layout Editor. Show the stacked canvas at run time.

...................................................................................................................................................... 11-10 Oracle Forms Developer: Build Internet Applications I

Creating a Stacked Canvas ......................................................................................................................................................

How to Create a Stacked Canvas in the Layout Editor 1 In the Object Navigator, double-click the object icon for the content canvas on which you wish to create a stacked canvas. The Layout Editor is displayed. 2 Click the Stacked Canvas tool in the toolbar. 3 Click and drag the mouse in the canvas where you want to position the stacked canvas. 4 Open the Property Palette of the stacked canvas. Set the canvas properties according to your requirements (described earlier in the lesson). Displaying Stacked Canvases in the Layout Editor You can display a stacked canvas as it sits over the content canvas in the Layout Editor. Check the display position of stacked canvases by doing the following: 1 Select View—>Stacked Views in the Layout Editor. The Stacked/Tab Canvases dialog box is displayed, with a list of all the stacked canvases assigned to the same window as the current content canvas. 2 Select the stacked canvases you want to display in the Layout Editor. Note: [Ctrl] + click to clear a stacked canvas that was previously selected.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 11-11

Lesson 11: Working with Other Canvases ......................................................................................................................................................

Toolbars • •

Special type of canvas for tool items Three types: – Vertical toolbar – Horizontal toolbar – MDI toolbar



Provide: – Standard look and feel – Alternative to menu or function key operation

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 11-12 Oracle Forms Developer: Build Internet Applications I

Creating a Toolbar ......................................................................................................................................................

Creating a Toolbar What Is a Toolbar Canvas? A toolbar canvas is a special type of canvas that you can create to hold buttons and other frequently used GUI elements. The Three Toolbar Types • Vertical toolbar: Use a vertical toolbar to position all your tool items down the left or right hand side of your window. • Horizontal toolbar: Use a horizontal toolbar to position all your tool items and controls across the top or bottom of your window. • MDI toolbar: Use an MDI toolbar to avoid creating more than one toolbar for a Form Builder application that uses multiple windows. Uses and Benefits of Toolbars • Provide a standard look and feel across canvases displayed in the same window. • Decrease form module maintenance time. • Increase application usability. • Create applications similar to others used in the same environment. • Provide an alternative to menu or function-key driven applications. Note: The MDI toolbar is available only for Microsoft Windows.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 11-13

Lesson 11: Working with Other Canvases ......................................................................................................................................................

Toolbar Related Properties •

Canvas properties: – Canvas Type – Window – Width – Height

Copyright  Oracle Corporation, 2000. All rights reserved.

Toolbar Related Properties •

Window properties: – Horizontal Toolbar Canvas – Vertical Toolbar Canvas



Form Module properties: – Form Horizontal Toolbar Canvas – Form Vertical Toolbar Canvas

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 11-14 Oracle Forms Developer: Build Internet Applications I

Creating a Toolbar ......................................................................................................................................................

Toolbar Related Properties Once you create a toolbar canvas, you must set its required properties as well as the required properties of the associated window. For MDI toolbars, you must set the required form module properties. Canvas Property Canvas Type

Width Height

Function Specifies the type of canvas; for a toolbar canvas, set to Horizontal Toolbar or Vertical Toolbar Specifies which window the toolbar displays in Determines the width of the toolbar Determines the height of the toolbar

Window Property Horizontal Toolbar Canvas/ Vertical Toolbar Canvas

Function Identifies the horizontal/vertical toolbar to display in this window

Form Module Property Form Horizontal Toolbar Canvas/ Form Vertical Toolbar Canvas

Function Identifies the horizontal/vertical toolbar to display in the MDI window

Window

How to Create a Toolbar Canvas 1 Create a new canvas in the Object Navigator. 2 If the Property Palette is not already displayed, click the new canvas entry and select Tools—>Property Palette. 3 Set the canvas properties that are described in the above table. 4 In the Object Navigator select one of the following: - The window in which you want to display the toolbar (for a form window toolbar) - The Form module (for an MDI Toolbar) 5 Set the Horizontal/Vertical Toolbar Canvas properties. 6 Add GUI elements, boilerplate text, and graphics, as required. Note: The width of a horizontal toolbar is set to the width of the window (for example, content canvas). Likewise, the height of a vertical toolbar is set to the height of the window.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 11-15

Lesson 11: Working with Other Canvases ......................................................................................................................................................

Tab Canvas •

Enables you to organize and display related information on separate tabs

• • •

Consists of one or more tab pages Provides easy access to data Created in: – Object Navigator – Layout Editor

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Although it is possible to get rid of a content canvas after creating a tab canvas, it is still highly recommended that there be at least one content canvas for each window in your form application.

...................................................................................................................................................... 11-16 Oracle Forms Developer: Build Internet Applications I

Creating a Tab Canvas ......................................................................................................................................................

Creating a Tab Canvas What Is a Tab Canvas? A tab canvas is a a special type of canvas that enables you to organize and display related information on separate tabs. Like stacked canvases, tab canvases are displayed on top of a content canvas. What Is a Tab Page? A tab page is a subobject of a tab canvas. Each tab canvas is made up of one or more tab pages. A tab page displays a subset of the information in the entire tab canvas. Each tab page has a labeled tab that end users can click to access information on the page. Each tab page occupies an equal amount of space on the tab canvas. Uses and Benefits of Tab Canvases • Create an overlay effect within a single window. • Display large amounts of information on a single canvas. • Hide information. • Easily access required information by clicking the tab. Creating a Tab Canvas • Create an empty tab canvas in either of the following: - Object Navigator - Layout Editor • Define one or more tab pages for the tab canvas. • Place items on the tab pages.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 11-17

Lesson 11: Working with Other Canvases ......................................................................................................................................................

Tab Canvas Related Properties 4 1

3

2

Copyright  Oracle Corporation, 2000. All rights reserved.

1

Viewport X/Y position

2

Viewport width

3

Viewport height

4

Tab attachment edge

...................................................................................................................................................... 11-18 Oracle Forms Developer: Build Internet Applications I

Creating a Tab Canvas ......................................................................................................................................................

Tab Canvas Related Properties Once you create a tab canvas and its tab pages, you must set the required properties for both of these objects. Place items on a tab page by setting the required item properties. Tab Canvas Property

Function

Viewport X Position

Specifies the X coordinate of the tab canvas upper-left corner

Viewport Y Position

Specifies the Y coordinate of the tab canvas upper-left corner

Viewport Width

Specifies the width of the view for the tab canvas

Viewport Height

Specifies the height of the view for the tab canvas

Corner Style

Specifies the shape of the labelled tabs on the tab canvas (Select from Chamfered, Square, and Rounded)

Tab Attachment Edge

Specifies the location where tabs are attached to the tab canvas

Width Style

Specifies whether the width of the tab will vary based upon the length of the tab page label

Active Style

Specifies whether the tab page label displays in bold face when that tab page is active

Tab Page Property

Function

Label

Specifies the text label that appears on the tab page’s tab at run time

Item Property

Function

Canvas

Specifies the tab canvas on which the item will be displayed

Tab Page

Specifies the tab page on which the item will be displayed

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 11-19

Lesson 11: Working with Other Canvases ......................................................................................................................................................

Creating a Tab Canvas

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 11-20 Oracle Forms Developer: Build Internet Applications I

Creating a Tab Canvas ......................................................................................................................................................

How to Create a Tab Canvas in the Object Navigator 1 Click the Canvases node in the Object Navigator. 2 Click the Create icon. A new canvas entry displays. 3 If the Property Palette is not already displayed, click the new canvas entry and select Tools—>Property Palette. 4 Set the Canvas Type property to Tab. Additionally, set the canvas properties according to your requirements (described earlier in the lesson). 5 Expand the canvas node in the Object Navigator. The Tab Pages node displays. 6 Click the Create icon. A tab page displays in the Object Navigator, with a default name of PAGEXX. The Property Palette takes on its context. 7 Set the tab page properties according to your requirements (described earlier in the lesson). 8 Create additional tab pages by repeating steps 6 and 7. How to Create a Tab Canvas in the Layout Editor 1 In the Object Navigator, double-click the object icon for the content canvas on which you want to create a tab canvas. The Layout Editor displays. 2 Click the Tab Canvas tool in the toolbar. 3 Click and drag the mouse in the canvas where you want to position the tab canvas. Form Builder creates a tab canvas with two tab pages by default. 4 Open the Property Palette of the tab canvas. Set the canvas properties according to your requirements (described earlier in the lesson). 5 Create additional tab pages, if required, in the Object Navigator. 6 Set the tab page properties according to your requirements (described earlier in the lesson).

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 11-21

Lesson 11: Working with Other Canvases ......................................................................................................................................................

Placing Items on a Tab Canvas • •

Place items on each tab page for user interaction. Set the item properties: – Canvas – Tab Page

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note When you add an item to a tab page, make sure the entire item is completely within the tab page region. You can resize the tab canvas viewport in the Layout Editor or in the Property Palette of the tab canvas by changing its Viewport Width and Height properties.

...................................................................................................................................................... 11-22 Oracle Forms Developer: Build Internet Applications I

Creating a Tab Canvas ......................................................................................................................................................

Placing Items on a Tab Page Once you create a tab canvas and related tab pages, you must place individual items on the tab pages that the end users can interact with at run time. To accomplish this, do the following: • Open the Property Palette of the item. • Set the item’s Canvas and Tab Page properties of the item to the desired tab canvas and tab page. Note: Display the tab canvas as it sits on top of the content canvas, by selecting View—>Stacked View in the Layout Editor.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 11-23

Lesson 11: Working with Other Canvases ......................................................................................................................................................

Summary • • •

Creating an overlay effect with a stacked canvas Creating a toolbar Creating a tab canvas

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 11-24 Oracle Forms Developer: Build Internet Applications I

Summary ......................................................................................................................................................

Summary In this lesson, you should have learned how to: • Create an overlay effect with a stacked canvas • Create a toolbar • Create a tabbed canvas

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 11-25

Lesson 11: Working with Other Canvases ......................................................................................................................................................

Practice 11 Overview

This practice covers the following topics:

• • • •

Creating a toolbar canvas Creating a stacked canvas Creating a tab canvas Adding tab pages to the tab canvas

Copyright  Oracle Corporation, 2000. All rights reserved.

Note For solutions to this practice, see Practice 11 in Appendix A, “Practice Solutions.”

...................................................................................................................................................... 11-26 Oracle Forms Developer: Build Internet Applications I

Practice 11 Overview ......................................................................................................................................................

Practice 11 Overview In this practice session, you will create different types of canvases: stacked canvas, toolbar canvas, and tab canvas. • Create a horizontal toolbar canvas in the ORDERS form. Create new buttons in the Control block, and place them on the horizontal toolbar. Save and run the form. • Create a stacked canvas in the ORDERS form to add some help text. Position the canvas in the center of the window. Create a button in the Control block. This button will be used later to display the stacked canvas. Add help text on the stacked canvas. Save and run the form. • Create a tab canvas in the CUSTOMERS form. Create three tab pages on this canvas, and make sure that each tab page displays the appropriate information. Save and run the form.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 11-27

Lesson 11: Working with Other Canvases ......................................................................................................................................................

Practice 11 Toolbar Canvases 1 In the ORDGXX form, create a horizontal toolbar canvas called Toolbar in the WIN_ORDER window, make it the standard toolbar for that window. Suggested height is 30. 2 Save, compile, and run the form to test. Notice that the toolbar now uses part of the window’s space. Adjust the window size accordingly. Create three buttons in the CONTROL block, as detailed below, and place them on the Toolbar canvas. Button Name Stock_Button

Show_Help_Button

Exit_Button

Details Label: Stock Mouse Navigate: No Keyboard Navigable: No Canvas: Toolbar Label: Show Help Mouse Navigate: No Keyboard Navigable: No Canvas: Toolbar Label: Exit Mouse Navigate: No Keyboard Navigable: No Canvas: Toolbar

Suggested positions for the buttons are shown in the following illustration:

...................................................................................................................................................... 11-28 Oracle Forms Developer: Build Internet Applications I

Practice 11 ......................................................................................................................................................

Stacked Canvases 1 Create a stacked canvas named CV_HELP to display help in the WIN_ORDER window of the ORDGXX form. Suggested visible size is Viewport Width 270, Viewport Height 215 (points). Place some application help text on this canvas. 2 Position the view of the stacked canvas so that it appears in the center of WIN_ORDER. Make sure it will not obscure the first enterable item. Do this by planning the top-left position of the view in the Layout Editor, while showing CV_ORDER. Define the Viewport X and Viewport Y Positions in the Property Palette. Do not move the view in the Layout Editor. 3 Organize CV_HELP so that it is the last canvas in sequence. Do this in the Object Navigator. (This ensures the correct stacking order at run time.) 4 Save and compile the form. Deploy the form on the Web to test the changes. Note that the stacked canvas is displayed all the time, providing that it does not obscure the current item in the form. 5 Switch off the Visible property of CV_HELP, then create a button in the control block to hide the Help information when it is no longer needed. We will add the code later. Display this button on the CV_HELP canvas. Button Name Hide_Help_Button

Details Label: Hide Help, Canvas: CV_HELP Mouse Navigate: No

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 11-29

Lesson 11: Working with Other Canvases ......................................................................................................................................................

Tab Canvases Modify the CUSTGXX form in order to use a tab canvas: 1 In the Layout Editor, delete the frame object that covers S_CUSTOMER block. Create a tab canvas. In the Layout Editor set the Background Color property to gray, Tab style property to Square, and Bevel property to None. 2 Rename this tab canvas TAB_CUSTOMER. Create three tab pages and label them as Address, Billing, and Comments. 3 Design the tab pages according to the following screenshots. Set the item properties to make them visible on the relevant tab pages.

...................................................................................................................................................... 11-30 Oracle Forms Developer: Build Internet Applications I

Practice 11 ......................................................................................................................................................

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 11-31

Lesson 11: Working with Other Canvases ......................................................................................................................................................

...................................................................................................................................................... 11-32 Oracle Forms Developer: Build Internet Applications I

Practice 11 ......................................................................................................................................................

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 11-33

Lesson 11: Working with Other Canvases ......................................................................................................................................................

Tab Canvases (continued) 4 Reorder the items according to the tab page sequence. Ensure that the user does not move from one tab page to another when tabbing through items. Set Next Navigation Item and Previous Navigation Item properties according to the order of items in the tab pages. 5 Save and compile the form. Deploy the form on the Web.

...................................................................................................................................................... 11-34 Oracle Forms Developer: Build Internet Applications I

12 ................................

Introduction to Triggers

Lesson 12: Introduction to Triggers ......................................................................................................................................................

Objectives

After completing this lesson, you should be able to do the following:

• • • •

Define triggers Identify the different trigger categories Plan the type and scope of triggers in a form Describe the properties that affect the behavior of a trigger

Copyright  Oracle Corporation, 2000. All rights reserved.

Schedule Topic Lecture Total

Timing 15 minutes 15 minutes

...................................................................................................................................................... 12-2 Oracle Forms Developer: Build Internet Applications I

Introduction ......................................................................................................................................................

Introduction Overview Triggers are one of the most important mechanisms that you can use to modify or add to the functionality of a form. In this lesson, you learn the essential rules and properties of triggers so that you can use them throughout your application.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 12-3

Lesson 12: Introduction to Triggers ......................................................................................................................................................

Form Builder Triggers

PL/SQL

Queries Validation Navigation

Event

Fire PL/SQL

Interaction Internal event Errors/Messages

PL/SQL

Others Trigger types

Copyright  Oracle Corporation, 2000. All rights reserved.

Note Events cause the activation, or firing, of certain trigger types.

...................................................................................................................................................... 12-4 Oracle Forms Developer: Build Internet Applications I

What Is a Trigger? ......................................................................................................................................................

What Is a Trigger? A trigger is a program unit that is executed (fired) due to an event. You have already seen that Form Builder enables you to build powerful facilities into applications without writing a single line of code. You can use triggers to add or modify form functionality in a procedural way. As a result, you can define the detailed processes of your application. Every trigger that you define is associated with a specific event. Form Builder defines a vast range of events for which you can fire a trigger. These events include the following: • Query-related events • Data entry and validation • Logical navigation or physical mouse movement • Operator interaction with items in the form • Internal events in the form • Errors and messages Trigger Characteristics You write Form Builder triggers in PL/SQL. These triggers are mostly fired by events within a form module. (Menu modules can initiate an event in a form, but the form module owns the trigger that fires.) Note: Database events that occur on behalf of a form can fire certain Form Builder triggers, but these database triggers are different from Form Builder triggers. Trigger Components There are three main components to consider when you design a trigger in Form Builder: Component Trigger type Trigger code Trigger scope

Description Defines the specific event that will cause the trigger to fire The body of PL/SQL that defines the actions of the trigger The level in a form module at which the trigger is defined— determining the scope of events that will be detected by the trigger

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 12-5

Lesson 12: Introduction to Triggers ......................................................................................................................................................

Trigger Scope Component

Levels

• • •

Type

Scope Code

Form Block Item

Copyright  Oracle Corporation, 2000. All rights reserved.

Trigger Scope

Event

Event

Event

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 12-6 Oracle Forms Developer: Build Internet Applications I

Trigger Components ......................................................................................................................................................

Trigger Components Trigger Scope The scope of a trigger is determined by its position in the form object hierarchy, that is, the type of object under which you create the trigger. There are three possible levels: Scope Form level Block level Item level

Description The trigger belongs to the form and can fire due to events across the entire form The trigger belongs to a block and can only fire when this block is the current block The trigger belongs to an individual item and can only fire when this item is the current item

Some triggers cannot be defined below a certain level. For example, Post-Query triggers cannot be defined at item level, because they fire due to a global or restricted query on a block. By default, only the trigger that is most specific to the current location of the cursor fires. Consider the example in the diagram, opposite: • When the cursor is in the Date_Shipped item, a message fires the On-Message trigger of the Date_Shipped item, because this is more specific than the other triggers of this type. • When the cursor is elsewhere in the ORDERS block, a message causes the block-level On-Message trigger to fire, because its scope is more specific than the form-level trigger. (You are outside the scope of the item-level trigger.) • When the cursor is in the ITEMS block, a message causes the form-level On-Message trigger to fire, because the cursor is outside the scope of the other two On-Message triggers. Note: The On-Message trigger fires whenever Form Builder displays a message.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 12-7

Lesson 12: Introduction to Triggers ......................................................................................................................................................

Trigger Type Component

Type Scope Code

• • • • •

PrePostWhenOnKey-

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Form Builder supports user-named triggers as well as the standard built-in triggers. A user-named trigger is one that is named by the designer. These triggers only fire if called upon by another trigger using built-in code features. User-named triggers are supported for compatibility with early versions of the product.

...................................................................................................................................................... 12-8 Oracle Forms Developer: Build Internet Applications I

Trigger Components ......................................................................................................................................................

Trigger Type The trigger type determines which type of event fires it. There are more than 100 builtin triggers, each identified by a specific name. The name of a trigger identifies its type. All built-in trigger types are associated with an event, and their names always contain a hyphen (-). For example: • When-Validate-Item fires when Form Builder validates an item. • Pre-Query fires before Form Builder issues a query for a block. The first part of a trigger name (before the first hyphen) follows a standard convention; this helps you to understand the general nature of the trigger type, and plan the types to use. Trigger Prefix KeyOnPrePostWhen-

Description Fires in place of the standard action of a function key Fires in place of standard processing (used to replace or bypass a process) Fires on an event that occurs just before an action (for example, before a query is executed) Fires just after an action (for example, after a query is executed) Fires in addition to standard processing (used to augment functionality)

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 12-9

Lesson 12: Introduction to Triggers ......................................................................................................................................................

Trigger Code Component

Type

Scope Code

• • • •

Statements PL/SQL User subprograms Built-in subprograms

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 12-10 Oracle Forms Developer: Build Internet Applications I

Trigger Components ......................................................................................................................................................

Trigger Code The code of the trigger defines the actions for the trigger to perform when it fires. Write this code as an anonymous PL/SQL block by using the PL/SQL Editor. Note: You only need to enter the BEGIN. . . END structure in your trigger text if you start your block with a DECLARE statement or if you need to code subblocks for other reasons. Statements that you write in a trigger can be constructed as follows: • Standard PL/SQL constructs (assignments, control statements, and so on). • SQL statements that are legal in a PL/SQL block; these are passed to the server for execution. • Calls to user-named subprograms (procedures and functions) in the form, a library, or the database. • Calls to built-in subprograms and package subprograms; these are procedures and functions that are part of Oracle Forms Developer. Although you can include SQL statements in a trigger, keep in mind the following rules about their use: • INSERT, UPDATE, and DELETE statements must be placed only in transactional triggers. These triggers fire during the commit process. • Transaction control statements (COMMIT, ROLLBACK, SAVEPOINT) cannot be included directly as SQL trigger statements. These actions are carried out by Form Builder as a result of either commands or built-in procedures that you issue.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 12-11

Lesson 12: Introduction to Triggers ......................................................................................................................................................

Execution Hierarchy Form level

On-Message

On-Error

1 EH = Before Block level

On-Message

On-Error

2

Event

EH = After

4 EH = Override

On-Message

Item level

3 Event

EH = After

Copyright  Oracle Corporation, 2000. All rights reserved.

Note Broken lines indicate the analysis path before firing. EH stands for execution hierarchy. 1

Fires first

2

Fires second

3

Viewport height

4

Fires independently

Instructor Note Demonstration Create a block based on the S_REGION table. Create On-Error triggers at form level, block level, and item level (for S_REGION.id). Write the following code according to the level information: MESSAGE(‘Form/Block/Item level trigger fired’);

Set EH property to “before” for form level, “after” for both block and item level. Create a button and write the following code in a When-Button-Pressed trigger for this item: EXIT_FORM(NO_VALIDATE);

Run the form. Insert text into S_REGION.id, and navigate to another item. This causes the On-Error triggers to fire according to the EH settings. This demonstration is available in the EH.fmb file.

...................................................................................................................................................... 12-12 Oracle Forms Developer: Build Internet Applications I

Trigger Components ......................................................................................................................................................

Trigger Scope and Execution Hierarchy As already stated, when there is more than one trigger of the same type Form Builder normally fires the trigger most specific to the cursor location. You can alter the firing sequence of a trigger by setting the execution hierarchy (EH) trigger property. Execution hierarchy is a trigger property that controls what happens when there are triggers of the same type at different levels, but each trigger is within the scope of an event. The default setting is Override. Settings for execution hierarchy are: Setting

Description

Override After

Only the trigger most specific to the cursor location fires The trigger fires after firing the same trigger at the next highest level (if a trigger exists) The trigger fires before firing the same trigger at the next highest level (if one exists)

Before

In the cases of Before and After, you can fire more than one trigger of the same type due to a single event. However, you must define each trigger at a different level.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 12-13

Lesson 12: Introduction to Triggers ......................................................................................................................................................

Summary • • •

Trigger: Event-activated program units Type: Defines the event that fires it Prefixes: – Key– On– Pre– Post– When-

• •

Code: PL/SQL anonymous block Scope: Form, block, or item level Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Ask questions to test understanding of the lesson.

...................................................................................................................................................... 12-14 Oracle Forms Developer: Build Internet Applications I

Summary ......................................................................................................................................................

Summary In this lesson, you should have learned the essential rules and properties for triggers. • Triggers are event-activated program units. • The trigger type defines the event that fires the trigger. • Prefixes for trigger names are: - Key- On- Pre- Post- WhenEach has a specific meaning. • Trigger code consists of a PL/SQL anonymous block. • The trigger scope determines which events will be detected by the trigger. The three possible levels for a trigger are form, block, and item. • When an event occurs, the most specific trigger overrides the triggers at a more general level. This can be affected by execution hierarchy.

...................................................................................................................................................... Oracle Forms Developer: Build Intern2-15

Lesson 12: Introduction to Triggers ......................................................................................................................................................

...................................................................................................................................................... 12-16 Oracle Forms Developer: Build Internet Applications I

13 ................................

Producing Triggers

Lesson 13: Producing Triggers ......................................................................................................................................................

Objectives

After completing this lesson, you should be able to do the following:

• •

Write trigger code

• •

Describe the When-Button-Pressed trigger

Explain the use of built-in subprograms in Oracle Forms Developer applications Describe the When-Window-Closed trigger

Copyright  Oracle Corporation, 2000. All rights reserved.

Schedule Topic Lecture Practice Total

Timing 55 minutes 30 minutes 85 minutes

...................................................................................................................................................... 13-2 Oracle Forms Developer: Build Internet Applications I

Introduction ......................................................................................................................................................

Introduction Overview This lesson shows you how to create triggers. You specifically learn how to use builtin subprograms in Oracle Forms Developer applications.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 13-3

Lesson 13: Producing Triggers ......................................................................................................................................................

Creating a Trigger

Smart Triggers Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 13-4 Oracle Forms Developer: Build Internet Applications I

Defining Triggers in Form Builder ......................................................................................................................................................

Defining Triggers in Form Builder Using Smart Triggers When you click an object in the Object Navigator or Layout Editor by using the right mouse button, a pop-up menu displays that includes the item Smart Triggers. The Smart Triggers item expands to a list of common triggers that are appropriate for the selected object. When you click one of these triggers, the Form Builder automatically creates the trigger. Creating a New Trigger Using Smart Triggers is the easiest way to create a new trigger, but you can also do it from the Object Navigator, from the Layout Editor, or from the PL/SQL Editor if it is already open: • In the Object Navigator, select the Triggers node of the form, block, or item that will own the trigger. Select Navigator—>Create from the menu, or click Create in the toolbar. This invokes the Trigger LOV. • If the PL/SQL Editor is open, click New to create a new trigger. This invokes the Trigger LOV. • In the Layout Editor, select the object, and click the right mouse button to display the pop-up menu. Select PL/SQL Editor, if there is already a trigger attached to the item; its name and code appear in the editor. Click the New button to invoke the Triggers LOV. • Select the trigger type from the Triggers LOV. The trigger type and scope are now set in the PL/SQL Editor. You can enter the code for the trigger in the source pane of the editor. Using the PL/SQL Editor You are already familiar with the PL/SQL Editor. In Form Builder, the PL/SQL Editor has the following specific trigger components: Component Type Object Item Name Source pane

Description Set to trigger Enables you to set the scope to either Form Level or a specific block Enables you to change between specific items (at item level) to access other triggers Trigger name; enables you to switch to another existing trigger Where trigger code is entered or modified

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 13-5

Lesson 13: Producing Triggers ......................................................................................................................................................

Trigger Properties

General

Functional

Help

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Briefly explain the main properties, as explained on the following page. Execution hierarchy is explained in Lesson 12. Key triggers are detailed in the course Oracle Forms Developer: Build Internet Applications II.

...................................................................................................................................................... 13-6 Oracle Forms Developer: Build Internet Applications I

Defining Triggers in Form Builder ......................................................................................................................................................

Trigger Properties In the property palette, you can set the following trigger properties: General Property Name

Description Specifies the internal name of the trigger

Functional Property Trigger Style Fire in Enter Query Mode

Execution Hierarchy

Description PL/SQL: Trigger code is a PL/SQL block (default) V2: Trigger is inherited from version 2.3 or earlier Yes: Trigger can fire when an event occurs in Enter Query as well as Normal mode No: Trigger can fire only in Normal mode Override, Before, or After

Help Property Display in “Keyboard Help” “Keyboard Help” text

Description Set to Yes if you want the name or the description to appear in the Show Keys window; the default is No Set to Yes if you want to specify the trigger description; this property is valid for Key- triggers

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 13-7

Lesson 13: Producing Triggers ......................................................................................................................................................

PL/SQL Editor

Split view

Copyright  Oracle Corporation, 2000. All rights reserved.

PL/SQL Editor Syntax Palette

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 13-8 Oracle Forms Developer: Build Internet Applications I

PL/SQL Editor Features ......................................................................................................................................................

PL/SQL Editor Features Automatic Formatting and Coloring of PL/SQL Code • Automatic Indenting and Color Syntax highlighting • Drag and Drop text Manipulation • Unlimited Undo/Redo Multiple Split Views You can create up to four separate views of the current program unit in the PL/SQL Editor by using split bars. Syntax Palette The Syntax Palette enables you to display and copy the constructs of PL/SQL language elements and build packages into an editor. To invoke the Syntax Palette, select Program—>Syntax Palette from the menu system. Global Search and Replace The Find and Replace in Program Units dialog box enables you to search for text across multiple program units without opening individual instances of the Program Unit Editor. Choose to replace every occurrence of the search text string found or in selected occurrences only. Invoke the Find and Replace in Program Units dialog box by selecting Program—>Find and Replace PL/SQL from the menu system. Instructor Note Only the Syntax Palette is shown in the slide. Demonstrate both of these features in Form Builder. Things to Remember About the PL/SQL Editor • New or changed text in triggers remains uncompiled until you click Compile. (If you select File—>Compile from the menu, it will compile all uncompiled code in the document.) • Compiling triggers that contain SQL require connection to the database. • All uncompiled triggers are compiled when the form module is compiled. The Block and Item pop-up lists do not change the current trigger scope. They enable you to switch to another trigger.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 13-9

Lesson 13: Producing Triggers ......................................................................................................................................................

Database Trigger Editor

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 13-10 Oracle Forms Developer: Build Internet Applications I

Database Trigger Editor ......................................................................................................................................................

Database Trigger Editor The logical grouping of items within the Database Trigger Editor enables developers to create row and statement triggers easily. An error message box displays an error when you try to retrieve, store, or drop an invalid trigger. To create a database trigger by using the Database Trigger Editor, perform the following steps: 1 In the Object Navigator, expand the Database Objects node to display the schema nodes. 2 Expand a schema node to display the database objects. 3 Expand the Tables node to display the schema’s database tables. 4 Select and expand the desired table. 5 Select the Triggers node and choose Navigator-Create. The Database Trigger Editor appears. 6 In the Database Trigger Editor, define and save the desired program units.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 13-11

Lesson 13: Producing Triggers ......................................................................................................................................................

Trigger PL/SQL Blocks . BEGIN

. END; Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Explain the general structure of a trigger code. The examples that follow are mainly aimed at showing possible structures; their detailed content is not very important at this stage.

...................................................................................................................................................... 13-12 Oracle Forms Developer: Build Internet Applications I

Writing the Trigger Code ......................................................................................................................................................

Writing the Trigger Code Trigger PL/SQL Blocks The code text of a Form Builder trigger is a PL/SQL block that consists of three sections: • A declaration section for variables, constants, and exceptions (optional) • An executable statements section (required) • An exception handlers section (optional) If your trigger code does not require defined variables, you do not need to include the BEGIN and END keywords; they are added implicitly. Example If the trigger does not require declarative statements, the BEGIN and END keywords are optional. When-Validate_Item trigger: IF :S_ITEM.price IS NULL THEN :S_ITEM.price := :S_ITEM.stdprice; END IF; calculate_total; -- User-named procedure

Example If the trigger requires declarative statements, the BEGIN and END keywords are required. When-Button-Pressed trigger: DECLARE vn_discount NUMBER; BEGIN vn_discount:=calculate_discount(:S_ITEM.product_id,:S_ITEM.quantity); MESSAGE(’Discount: ’||TO_CHAR(vn_discount)); END;

Example To handle exceptions, include EXCEPTION section in trigger. Post-Insert trigger: INSERT INTO LOG_TAB (LOG_VAL, LOG_USER) VALUES(:S_DEPT.id,:GLOBAL.username); EXCEPTION WHEN OTHERS THEN MESSAGE(’Error! ’,||SQLERRM);

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 13-13

Lesson 13: Producing Triggers ......................................................................................................................................................

Variables in Form Builder •

PL/SQL variables must be declared in a trigger or defined in a package



Form Builder variables – Are not formally declared in PL/SQL – Need a colon prefix in reference

Copyright  Oracle Corporation, 2000. All rights reserved.

Form Builder Variables •

Items For presentation and user interaction



Global variables Session-wide character variable



System variables Form status and control



Parameters Passing values in and out of module

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 13-14 Oracle Forms Developer: Build Internet Applications I

Writing the Trigger Code ......................................................................................................................................................

Using Variables in Form Builder In triggers and subprograms, Form Builder generally accepts two types of variables for storing values: • PL/SQL variables: These must be declared in a DECLARE section, and remain available until the end of the declaring block. They are not prefixed by a colon. If declared in a PL/SQL package, a variable is accessible across all triggers that access this package. • Form Builder variables: Variable types maintained by the Form Builder. These are seen by PL/SQL as external variables, and require a colon (:) prefix to distinguish them from PL/SQL objects (except when their name is passed as a character string to a subprogram). Form Builder variables are not formally declared in a DECLARE section, and can exist outside the scope of a PL/SQL block. Form Builder Variables The following variables are available for the storage and manipulation of values: Form Builder Variable Type Item (text, list, check box, and so on) Global variable System variable Parameter

Description Scope: Current form and attached menu Use: Presentation and interaction with user Scope: All modules in current session Use: Session-wide storage of character data Scope: Current form and attached menu Use: Form status and control Scope: Current module Use: Passing values in and out of module

Initializing Global Variables with Default Value You can use the DEFAULT_VALUE built-in to assign a value to a global variable. Form Builder creates the global variable if it does not exist. If the value of the indicated variable is not null, DEFAULT_VALUE does nothing. The following example creates a global variable named country and initializes it with the value TURKEY: Default_Value(’TURKEY’,’GLOBAL.country’);

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 13-15

Lesson 13: Producing Triggers ......................................................................................................................................................

Syntax of Variables • • • •

:block_name.item_name :GLOBAL.variable_name :SYSTEM.variable_name :PARAMETER.name

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Explain syntax of above variables with reference to examples opposite. What kind of object is OK_TO_LEAVE_BLOCK? Point out that more specific examples and how to manage these variables will be covered in later lessons.

...................................................................................................................................................... 13-16 Oracle Forms Developer: Build Internet Applications I

Writing the Trigger Code ......................................................................................................................................................

Examples of Form Builder Variables In each of the following examples, note that a colon (:) prefixes Form Builder variables, and a period (.) separates the components of their name. The examples are not complete triggers. Example References to items should be prefixed by the name of the owning Form Builder block, which prevents ambiguity when items of the same name exist in different blocks. This is also more efficient than the item name alone: :BLOCK3.product_id := :BLOCK2.product_id;

Example References to global variables must be prefixed by the word global. They may be created as the result of an assignment: :GLOBAL.customer_id := :BLOCK1.id;

Example References to system variables must be prefixed by the word system: IF :SYSTEM.MODE = ’NORMAL’ THEN ok_to_leave_block := TRUE; END IF;

Example Parameters defined at design-time have the prefix parameter: IF :PARAMETER.starting_point = 2 THEN GO_BLOCK(’BLOCK2’); -- built-in procedure END IF;

Removing Global Variables You can use the ERASE built-in to remove a global variable. Globals always allocate 255 bytes of storage. To ensure that performance is not impacted more than necessary, always erase any global variable when it is no longer needed.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 13-17

Lesson 13: Producing Triggers ......................................................................................................................................................

Form Builder Built-in Subprograms Built-ins belong to either:



The Standard Extensions package where no prefix is required



Another Form Builder package where a prefix is required

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 13-18 Oracle Forms Developer: Build Internet Applications I

Adding Functionality Using Built-in Subprograms ......................................................................................................................................................

Adding Functionality Using Built-in Subprograms Form Builder Built-in Subprograms Form Builder provides a set of predefined subprograms as part of the product. These subprograms are defined within built-in packages as either a procedure or function. Form Builder built-in subprograms belong to one of the following: • Standard Extensions packages: These built-ins are integrated into the Standard PL/SQL command set in Form Builder. You can call them directly, without any package prefix. You can use more than one hundred standard built-ins. • Other Form Builder packages: Subprograms in other built-in packages provide functionality related to a particular supported feature. These require the package name as a prefix when called. Package DDE DEBUG EXEC_SQL FTREE OLE2 ORA_FFI ORA_NLS ORA_PROF TEXT_IO PECS TOOL_ENV TOOL_ERR TOOL_RES VBX

WEB

Description Provides Dynamic Data Exchange support Provides built-ins for debugging PL/SQL program units Provides built-ins for executing dynamic SQL within PL/SQL procedures Provides built-ins for manipulating hierarchical tree items Provides a PL/SQL API for creating, manipulating, and accessing attributes of OLE2 automation objects Provides built-ins for calling out to foreign (C) functions from PL/SQL Enables you to extract high-level information about your current language environment Provides built-ins for tuning PL/SQL program units Provides built-ins to read and write information from and to files Provides built-ins for the Performance Event Collection Services; provided for backward compatibility Enables you to interact with Oracle environment variables Enables you to access and manipulate the error stack created by other built-in packages such as Debug Provides built-ins to manipulate resource files Provides built-ins for controlling and interacting with VBX controls; this package works only in a 16-bit environment and is provided for backward compatibility Provides built-ins for the Web environment

All the built-in subprograms used in this lesson are part of the Standard Extensions package.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 13-19

Lesson 13: Producing Triggers ......................................................................................................................................................

Limits of Use •

Unrestricted built-ins are allowed in any trigger or subprogram.



Restricted built-ins are allowed only in certain triggers and subprograms called from such triggers.



Consult the Help system.

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 13-20 Oracle Forms Developer: Build Internet Applications I

Adding Functionality Using Built-in Subprograms ......................................................................................................................................................

Where Can Built-in Subprograms Be Used? You can call built-ins in any trigger or user-named subprogram in which you use PL/SQL. However, some built-ins provide functionality that is not allowed in certain trigger types. Built-ins are therefore divided into two groups: • Unrestricted built-ins: Unrestricted built-ins do not affect logical or physical navigation and can be called from any trigger, or from any subprogram. • Restricted built-ins: Restricted built-ins affect navigation in your form, either external screen navigation, or internal navigation. You can call these built-ins only from triggers while no internal navigation is occurring. The online Help specifies which groups of built-ins can be used in each trigger.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 13-21

Lesson 13: Producing Triggers ......................................................................................................................................................

Using Built-in Definitions

4 3 1 2 Copyright  Oracle Corporation, 2000. All rights reserved.

1

Open PL/SQL code

2

Select built-in

3

Paste names or arguments

4

Modify pasted code

Instructor Note Point out the overloadings in the list within the Object Navigator. You can use the find feature in the Object Navigator to bypass this overload in the list. Point out how you can locate the built-in in Help. Highlight an example using a built-in. Copy it, then close Help and paste in the PL/SQL Editor. Demonstration Use SHOW_LOV to demonstrate how you can paste prototype syntax for a built-in from the Object Navigator into a trigger or program unit.

...................................................................................................................................................... 13-22 Oracle Forms Developer: Build Internet Applications I

Adding Functionality Using Built-in Subprograms ......................................................................................................................................................

Using Built-in Definitions in the Form Builder When you are writing a trigger or program unit, the Form Builder enables you to look up built-in definitions, and optionally copy their names and argument prototypes into your code. 1 Place the cursor at the point in your PL/SQL code (in the PL/SQL Editor) where a built-in subprogram is to be called. 2 Expand the Built-in Packages node in the Navigator, and select the procedure or function that you need to use (usually from Standard Extensions). 3 If you want to copy the built-in prototype arguments or name, or both, select Navigator—>Paste Name or Navigator—>Paste Arguments from the menus (Paste Arguments includes the built-in name also). 4 The definition of the built-in is copied to the cursor position in the PL/SQL Editor, where you can insert your own values for arguments, as required. Note: A subprogram can be either a procedure or a function. Built-in subprograms are therefore called in two distinct ways: • Built-in procedures: Called as a complete statement in a trigger or program unit with mandatory arguments. • Built-in functions: Called as part of a statement, in a trigger or program unit, at a position where the function’s return value will be used. Again, the function call must include any mandatory arguments. Example The SHOW_LOV built-in is a function that returns a Boolean value (indicating whether the user has chosen a value from the LOV). It might be called as part of an assignment to a boolean variable. This is not a complete trigger. DECLARE customer_chosen BOOLEAN; BEGIN customer_chosen := SHOW_LOV(’customer_list’); . . .

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 13-23

Lesson 13: Producing Triggers ......................................................................................................................................................

Useful Built-Ins • • • • • • • •

EDIT_TEXTITEM ENTER_QUERY, EXECUTE_QUERY EXIT_FORM GO_BLOCK, GO_ ITEM GET_ITEM_PROPERTY, SET_ITEM_PROPERTY MESSAGE SHOW_ALERT, SHOW_ EDITOR, SHOW_ LOV SHOW_VIEW, HIDE_VIEW

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 13-24 Oracle Forms Developer: Build Internet Applications I

Adding Functionality Using Built-in Subprograms ......................................................................................................................................................

Useful Built-ins for Adding Functionality to Items Here are just a few built-ins that you can use in triggers to add functionality to items. They are discussed in later lessons. Built-in Subprogram EDIT_TEXTITEM procedure ENTER_QUERY procedure

EXECUTE_QUERY procedure

EXIT_FORM procedure GET_ITEM_PROPERTY function GO_BLOCK procedure GO_ITEM procedure HIDE_VIEW procedure LIST_VALUES procedure MESSAGE procedure SET_ITEM_PROPERTY procedure SHOW_ALERT function SHOW_EDITOR procedure

SHOW_LOV function SHOW_VIEW procedure

Description Invokes the Form Runtime item editor for the current text item Clears the current block, and creates a sample record (Operators can then specify query conditions before executing the query with a menu or button command. If there are changes to commit, the Form Builder prompts the operator to commit them before continuing ENTER_QUERY processing.) Clears the current block, opens a query, and fetches a number of selected records (If there are changes to commit, Form Builder prompts the operator to commit them before continuing EXECUTE_QUERY processing.) Exits current form (or cancels query, if in ENTER-QUERY mode) Returns specified property values for the specified item Navigates to the specified block Navigates to the specified item Hides the indicated canvas Invokes the LOV attached to the current item Displays specified text on the message line Changes setting of specified property for an item Displays the given alert, and returns a numeric value when the operator selects one of three alert buttons Displays the specified editor at the given coordinates and passes a string to the editor, or retrieves an existing string from the editor Invokes a specified LOV and returns a Boolean value, indicating whether user selected a value from the list Displays the indicated canvas at the coordinates specified by the X Position and Y Position of the canvas property settings (If the view is already displayed, SHOW_VIEW raises it in front of any other views in the same window.)

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 13-25

Lesson 13: Producing Triggers ......................................................................................................................................................

When-Button-Pressed Trigger • •

Fires when the operator clicks a button.



Use to provide convenient navigation, to display LOVs and many other frequently used functions.

Accepts restricted and unrestricted built-ins.

Example GO_BLOCK(‘Stock’); EXECUTE_QUERY;

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 13-26 Oracle Forms Developer: Build Internet Applications I

Using Triggers ......................................................................................................................................................

Using Triggers When-Button-Pressed Trigger This trigger fires when the user selects a button. You can define the trigger on an individual item or at higher levels if required. When-Button-Pressed accepts both restricted and unrestricted built-ins. You can use buttons to provide a wide range of functions for users. These functions include: • Navigation • Displaying LOVs • Invoking calculations and other functions Example The Stock_Button in the CONTROL block is situated on the CV_INVENTORY canvas of the ORDERS form. When pressed, the button activates the When-Button-Pressed trigger. The trigger code results in navigation to the S_INVENTORY block and execution of a query on the S_INVENTORY block. GO_BLOCK(’S_INVENTORY’); EXECUTE_QUERY;

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 13-27

Lesson 13: Producing Triggers ......................................................................................................................................................

When-Window-Closed Trigger •

Fires when the operator closes a window by using a window manager-specific close command.

• •

Accepts restricted and unrestricted built-ins. Used to programmatically close a window when the operator issues a window manager-specific close command. You can close a window by using built-ins.

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 13-28 Oracle Forms Developer: Build Internet Applications I

Using Triggers ......................................................................................................................................................

When-Window-Closed Trigger This trigger fires when you close a window by using a window manager-specific close command. You define this trigger at the form level. The When-Window-Closed trigger accepts both restricted and unrestricted built-ins. Use this trigger to close a window programmatically when the operator issues the window manager Close command. Form Builder does not close the window when the operator issues a window manager-specific close command; it only fires When-Window-Closed trigger. It is the developer’s responsibility to write the required functionality in this trigger. You can close a window with the HIDE_WINDOW, SET_WINDOW_PROPERTY, and EXIT_FORM built-in subprograms. You cannot hide the window that contains the current item. Example When the operator issues the window manager-specific Close command, the following code in a When-Window-Closed trigger closes the W_INVENTORY window by setting the VISIBLE property to FALSE. GO_ITEM(’S_ORD.ID’): SET_WINDOW_PROPERTY(’W_INVENTORY’, VISIBLE, PROPERTY_FALSE);

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 13-29

Lesson 13: Producing Triggers ......................................................................................................................................................

Summary

To produce a trigger: 1. Select a scope in the Object Navigator. 2. Create a trigger and select a Name from the LOV, or use the SmartTriggers menu option. 3. Define code in the PL/SQL Editor. 4. Compile.

Copyright  Oracle Corporation, 2000. All rights reserved.

Summary •

Find built-ins in the Navigator under Built-in Packages: – Paste built-in name and arguments to your code by using the Paste Name and Arguments option. – Refer to online Help.



The When-Button-Pressed trigger provides a wide range of functionality to users.



Use the When-Window-Closed trigger to provide functionality when the user issues a window manager-specific close command. Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 13-30 Oracle Forms Developer: Build Internet Applications I

Using Triggers ......................................................................................................................................................

Practice 13 Overview

This practice covers the following topics:

• •

Using built-ins to display LOVs



Using built-ins to display and hide the Help stack canvas

Using the When-Button-Pressed and When-Window-Closed triggers to add functionality to items

Copyright  Oracle Corporation, 2000. All rights reserved.

Note For solutions to this practice, see Practice 13 in Appendix A, “Practice Solutions.”

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 13-31

Lesson 13: Producing Triggers ......................................................................................................................................................

Practice 13 Overview This practice focuses on how to use When-Button-Pressed and When-Window-Closed triggers. • Using built-ins to display LOVs • Using When-Button-Pressed and When-Window-Closed triggers to add functionality to items • Using built-ins to display and hide the Help stacked canvas

...................................................................................................................................................... 13-32 Oracle Forms Developer: Build Internet Applications I

Practice 13 ......................................................................................................................................................

Practice 13 1 In the CUSTGXX form, write a trigger to display the Sales_Rep_Lov

when the Sales_Rep_Lov_Button is pressed. To create the When-Button-Pressed trigger, use the Smart Triggers feature. Find the relevant built-in in the Object Navigator under built-in packages, and use the “Paste Name and Arguments” feature. IF SHOW_LOV(’sales_rep_lov’) THEN NULL; END IF; 2 Create a When-Window-Closed trigger at the form level in order to exit 3 4 5 6 7

form. Save, compile, and run the form. In the ORDGXX form, write a trigger to display the Products_Lov when the Products_Lov_Button is selected. Write a trigger that exits the form when the Exit_Button is selected. Save, compile, and run the form. Create a When-Button-Pressed trigger on the CONTROL.Show_Help_Button that uses the SHOW_VIEW built-in to display the CV_HELP. SHOW_VIEW(’CV_HELP’);

8 Create a When-Button-Pressed trigger on

CONTROL.Hide_Help_Button that hides the CV_HELP. Use the HIDE_VIEW built-in to achieve this. HIDE_VIEW(’CV_HELP’); 9 Save and compile the form. Deploy the ORDGXX form on the Web to

test. Note: The stacked canvas, CV_HELP, displays only if the current item will not be obscured. Ensure, at least, that the first entered item in the form is one that will not be obscured by CV_HELP. You might decide to advertise Help only while the cursor is in certain items, or move the stacked canvas to a position that does not overlay enterable items. The CV_HELP canvas, of course, could also be shown in its own window, if appropriate. 10 Create a When-Button-Pressed trigger on CONTROL.Stock_Button that uses the GO_BLOCK built-in to display the S_INVENTORY block.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 13-33

Lesson 13: Producing Triggers ......................................................................................................................................................

...................................................................................................................................................... 13-34 Oracle Forms Developer: Build Internet Applications I

14 ................................

Debugging Triggers

Lesson 14: Debugging Triggers ......................................................................................................................................................

Objectives

After completing this lesson, you should be able to do the following:

• • •

Describe the components of the Debugger Run a form module in debug mode Debug PL/SQL code

Copyright  Oracle Corporation, 2000. All rights reserved.

Schedule Topic Lecture Practice Total

Timing 30 minutes 25 minutes 55 minutes

...................................................................................................................................................... 14-2 Oracle Forms Developer: Build Internet Applications I

Introduction ......................................................................................................................................................

Introduction Overview This lesson shows you how to debug triggers by using the PL/SQL Debugger to execute code one line at a time. This lesson also shows you how to view and change variables while using the Debugger.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 14-3

Lesson 14: Debugging Triggers ......................................................................................................................................................

Debugging Triggers

Monitor and debug triggers by:

• • •

Compiling correct errors in the PL/SQL Editor Displaying debug messages at run time Invoking the PL/SQL Debugger

Copyright  Oracle Corporation, 2000. All rights reserved.

Debugging Tips • • •

Connect to the database for SQL compilation.

• •

Define triggers at the correct level.

The line that fails is not always responsible. Watch for missing semicolons and quotation marks. Place triggers where the event will happen.

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 14-4 Oracle Forms Developer: Build Internet Applications I

Debugging Triggers ......................................................................................................................................................

Debugging Triggers How to Debug Triggers in Form Builder With Form Builder you can monitor and debug triggers in a number of ways: • Compiling: Syntax errors and object reference errors (including references to database objects) are reported when you compile a trigger or generate the form module. This enables you to correct these problems in the PL/SQL Editor before run time. • Running a form with run time parameter debug_messages=Yes: In Debug mode, you can request messages to be displayed to indicate when triggers fire. This helps you see whether certain triggers are firing, their origin and level, and the time at which they fire. • Invoking the PL/SQL Debugger: With the Debugger you can monitor the execution of code within a trigger (and other program units). You can step through the code on a line-by-line basis, and you can monitor called subprograms and variables as you do so. You can also submit arbitrary PL/SQL statements while the form is running, and modify variables. General Tips to Solve Trigger Problems • Make sure you are connected to the (correct) database when you compile triggers that contain SQL. Error messages can be deceiving. • The PL/SQL Editor reports the line that fails, but the error may be due to a dependency on an earlier line of code. • Missing semicolons (;) and mismatched quotes are a common cause of compile errors. Check for this if a compile error does not give an obvious indication to the problem. • If a trigger seems to fire too often, or on the wrong block or item in the form, check whether it is defined at the required level. For example, a form-level When-Validate-Item trigger fires for every changed item in the form. To check this, you can run the form with Debug Messages on. • For triggers that populate other items, make sure the trigger belongs to the object where the firing event will occur, not on the items to be populated.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 14-5

Lesson 14: Debugging Triggers ......................................................................................................................................................

Running a Form in Debug Mode Run Form Debug (Compiles automatically) Contains source code and executable run file

.FMX (Runs automatically)

Run Form in Debug Mode

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 14-6 Oracle Forms Developer: Build Internet Applications I

Debugging Triggers ......................................................................................................................................................

Running a Form Module in Debug Mode In Debug mode, you can monitor triggers that fire and use the PL/SQL Debugger. To interact with code in the Debugger, the run-time module (.fmx) must be rebuilt to include source versions of the form code. To run a form in Debug mode, follow these steps: 1 Click the Run Form Debug button in the Navigator, or select Program—>Run Form—>Debug from the menu. The form module is built and runs automatically. 2 When the form module is started, the PL/SQL Debugger is initially displayed so that you can enter Debug actions before the form begins running. When you dismiss the Debugger, the form is entered for running. Displaying Messages When Triggers Fire You can display messages that wait for acknowledgment before execution continues each time a trigger fires. These are displayed on the message line, and include the trigger’s type and scope. To display messages, run the form from the command line, specifying the Debug_Messages option. For example in Microsoft Windows: ifrun60 myform scott/tiger debug_messages=YES

Each message is displayed just before the execution of the trigger, enabling you to see the current state of the form before the effects of the trigger.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 14-7

Debugging Triggers ......................................................................................................................................................

The PL/SQL Debugger The PL/SQL Debugger enables you to perform the following tasks: • Step through program units and examine the units as they progress. • Examine or modify the state of variables during execution. • Set breakpoints to suspend execution, so that you can analyze the status of the application at a given point. • Define debug actions that will execute on certain events (Debug triggers). • Add PL/SQL statements during execution. The Debugger contains the following components (see slides on opposite page): 1

Navigator controls

Help, Create, Delete, Expand, Collapse, Expand All, Collapse All, Find (Control the Navigator pane as you do in the main Object Navigator.)

2

Source pane

A read-only copy of current program unit (You can select lines of code and set breakpoints in this pane.)

3

Navigator pane

Hierarchical list of programmatic objects (Functions the same as it does in main Object Navigator.)

4

Interpreter pane

Command line area where you enter PL/SQL and Debugger commands

5

Step Into (button)

Executes the STEP INTO command

6

Step Over (button)

Executes the STEP OVER command

7

Step Out (button)

Executes the STEP OUT command

8

Go (button)

Executes the GO command

9

Reset (button)

Executes the RESET command

10

Close (button)

Closes the Debugger

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 14-9

Lesson 14: Debugging Triggers ......................................................................................................................................................

Invoking the Debugger and Breakpoints Debug mode

2 1 Copyright  Oracle Corporation, 2000. All rights reserved.

1

Select trigger

2

Set breakpoint

...................................................................................................................................................... 14-10 Oracle Forms Developer: Build Internet Applications I

Debugging Triggers ......................................................................................................................................................

Invoking the Debugger and Breakpoints You can invoke the Debugger at any time while a form is running in Debug mode by selecting Help—>Debug from the Runform menu. Menus and the Debugger When control is passed to the Debugger, the Main menu includes View, Debug, and Navigator options, each providing additional submenus for controlling the Debugger. Setting Breakpoints in a Trigger Breakpoints invoke the Debugger during code execution, and you can analyze and interact with triggers and other program units when specific points in the code are reached. A breakpoint invokes the Debugger just before execution of the line where the breakpoint is set. You can define a breakpoint in two ways. Method 1 1 Select the desired trigger in the Navigator pane. The Debugger displays its source in the Source pane. 2 Double-click the line in the Source pane where the breakpoint is to be set. You can now dismiss the Debugger, and it will reappear when the specified line is reached during trigger execution. Method 2 Other debug actions can be attached alternatively as follows: 1 Select the desired trigger, as in the first step of Method 1, and then select Debug—>Break from the menu. This invokes the PL/SQL Breakpoint dialog box. 2 In the trigger area of the Breakpoint dialog box, enter: RAISE DEBUG.BREAK. This raises an exception from the Debug package, which passes control to the Debugger when this line is subsequently reached during execution. With this method, you have set up a Breakpoint trigger from the Breakpoint dialog box, which fires each time the breakpoint is reached in the normal trigger. Note: Breakpoints must be attached to an executable statement in the body of the code. Comment lines or NULL commands are not valid for this purpose.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 14-11

Lesson 14: Debugging Triggers ......................................................................................................................................................

Breakpoint and Debug Triggers

Fire Statement Debug trigger Every statement

Breakpoint

Fire

Breakpoint trigger

Statement Fire Statement

Debugger

Program Unit Copyright  Oracle Corporation, 2000. All rights reserved.

Debug Triggers

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 14-12 Oracle Forms Developer: Build Internet Applications I

Debugging Triggers ......................................................................................................................................................

Breakpoint Triggers and Debug Triggers You may sometimes want to define debug actions that occur automatically, either on a breakpoint, or when certain program units and triggers are executed. Define debug actions as follows: • Breakpoint triggers: A trigger that fires on a breakpoint, and contains PL/SQL and DEBUG functions and procedures. - Select a line of code in the Source pane, where a breakpoint is to be set. - Select Debug—>Break from the menu, which invokes the Breakpoint dialog box. - Enter your debug code in the Trigger area, then click OK. • Debug triggers: Like Breakpoint triggers, you can define Debug triggers to fire when a breakpoint occurs. Debug triggers, however, can be attached to a program unit, or fired when each line of code is executed in that program unit. Note: Debug triggers only cause a breakpoint if you raise the DEBUG.BREAK exception within them. Otherwise, they perform their actions in the background. 1 Select a program unit or line of source code in the Debugger. 2 Select Debug—>Trigger from the menu. This opens the PL/SQL Trigger dialog box. 3 Enter your debug code in the Trigger body area, and then click OK. Disabling Debug Actions To disable debug actions during run time, you clear the Enabled check box in the PL/SQL trigger or Breakpoint dialog box. You can redisplay these dialogs by locating the debug action below the Debug Actions node in the Navigator, then double-clicking on the listed action you want to display. After selecting the listed action, you can use the pop-up menu to disable or enable the selected action by clicking the right mouse button.

...................................................................................................................................................... Oracle Forms Developer: Build Intern4-13

Lesson 14: Debugging Triggers ......................................................................................................................................................

Debug Commands

Step over Reset

1 2

Step out

Step into

GO

Copyright  Oracle Corporation, 2000. All rights reserved.

Note Your trigger code is often nested in the single PL/SQL block that Form Builder provides. 1

Trigger

2

Subprograms

...................................................................................................................................................... 14-14 Oracle Forms Developer: Build Internet Applications I

Debugging Triggers ......................................................................................................................................................

Useful Commands in the Debugger You can enter following commands in the Interpreter pane. Those marked with asterisks (*) have an equivalent toolbar button: Command .STEP INTO* .STEP OVER* .STEP OUT* .GO* .RESET* .SHOW LOCALS

Description Advances execution into the next subprogram called by this line Executes the subprogram without stepping into it; stops at the next line Resume to end of current level (subprogram) Resumes execution indefinitely Exits current subprogram now Displays all local variables (PL/SQL variables declared locally) and parameters

The following subprograms from the DEBUG package can be entered on the command line of the Debugger (in the Interpreter pane), or included in Debug and Breakpoint triggers. When you use them, you can display and set values for variables and parameters in the current trigger or subprogram scope: Subprogram DEBUG.INTERPRET(string)

DEBUG.GETx(varname)

DEBUG.SETx(varname,value)

Description A procedure that lets you nest an Interpreter command (like those above) as a string, and then execute from debug triggers A function that returns the value of variable varname. (x represents datatype (n for NUMBER, d for DATE, c for CHAR or VARCHAR2, i for PLS_INTEGER).) A procedure that sets a specified value for a variable. (x represents datatype (n for NUMBER, d for DATE, c for CHAR or VARCHAR2, i for PLS_INTEGER).)

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 14-15

Lesson 14: Debugging Triggers ......................................................................................................................................................

Debug Example Debug Example WHEN-BUTTONPRESSED

1

The results are: ?? …calls...

5

Procedure XYZ;

2 Function ABC;

4 3

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 14-16 Oracle Forms Developer: Build Internet Applications I

Debugging Triggers ......................................................................................................................................................

Example This simple example demonstrates some of the basic features available in the debugger. The example form consists of a single button with trigger code for the When-Button-Pressed event. The code works as follows: 1 The trigger calls the XYZ procedure, passing it a value for the xyz_param input parameter. 2 The XYZ procedure calls the ABC function passing it a value for the abc_param input parameter. PROCEDURE xyz(xyz_param IN NUMBER) IS v_results NUMBER; BEGIN v_results := ABC(10); v_results := v_results + xyz_param; MESSAGE(‘The results are: ‘ || TO_CHAR(v_results)); END xyz; 3 The ABC function multiplies two variables and adds the result to the

abc_param input parameter. 4 The ABC function returns the result to the XYZ procedure. 5 The XYZ procedure adds the result to the xyz_param and displays it in the console at the bottom of the form window. FUNCTION abc (abc_param IN NUMBER) RETURN NUMBER IS v_total NUMBER := 0; v_num2 NUMBER := 3; v_num6 NUMBER := 8; /*-- wrong value should be 6 */ BEGIN v_total := v_num3 * v_num6; v_total := v_total + abc_param; RETURN v_total; END abc;

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 14-17

Lesson 14: Debugging Triggers ......................................................................................................................................................

Debugger: Setting a Breakpoint

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note Demonstration Run the form DebugDemo.fmb to show the students how to use the debugger. Follow the steps which begin on the opposite page.

...................................................................................................................................................... 14-18 Oracle Forms Developer: Build Internet Applications I

Debugging Triggers ......................................................................................................................................................

Debugger: Setting a Breakpoint When you click the Debug Example button in the form, “134” displays at the bottom of the screen (console). However, the expected results were “128.” The syntax must be correct because everything compiled correctly. So, there must be something wrong in the logic of the application code within the form. The developer needs to debug the code to find why it produced the wrong results. 1 Run the DebugDemo form in Debug mode (use the Run Form Debug button), and locate the When-Button-Pressed trigger in Block1 in the Debugger. Set a breakpoint on the executable line (Source pane) that calls the procedure: 00001 BEGIN B(01) xyz(100); -- ’B(01)’ indicates the break 00003 END; 2 Dismiss the Debugger and the form runs. 3 Click the Debug Example button in the form. The program stops at the

breakpoint.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 14-19

Lesson 14: Debugging Triggers ......................................................................................................................................................

Debugger: Stepping into Code

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 14-20 Oracle Forms Developer: Build Internet Applications I

Debugging Triggers ......................................................................................................................................................

Debugger: Stepping into Code 4 The XYZ procedure now displays in the Source pane, with “=>” to mark current position at the beginning of the executable code. 00001 BEGIN 5 Click the Step Into button in the Debugger to advance into the XYZ

procedure. 00001 PROCEDURE xyz (xyz_param IN NUMBER)IS v_results NUMBER; 00002 BEGIN =>003 v_results := ABC(10); 00004 v_results := v_results + xyz_param; 00005 MESSAGE(‘The results are: ‘ || TO_CHAR(v_results)); 00006 END xyz; 6 Examine the Stack values for the xyz_param and v_results parameters

(as well as system variables). Everything looks normal in the xyz procedure. -Stack -[1]Procedure Body XYZ Line 3 |- XYZ_PARAM (NUMBER)= 100 |- V_RESULTS (NUMBER)=

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 14-21

Lesson 14: Debugging Triggers ......................................................................................................................................................

Debugger: Checking Variables

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 14-22 Oracle Forms Developer: Build Internet Applications I

Debugging Triggers ......................................................................................................................................................

Debugger: Stepping into Code (continued) 7 Click the Step Into button to enter the ABC function. Step through each of the opening assignment statement. Find the problem in the code (v_num6 is incorrectly set to 8 instead of 6). 00001 00002 00003 =>004 00005 00006

FUNCTION abc (abc_param IN NUMBER) RETURN NUMBER IS v_total NUMBER := 0; v_num3 NUMBER := 3; v_num6 NUMBER :=8; /*-- wrong value should be 6 */

8 Check the stack values of the v_total, v_num3, and v_num6 variables. ----------------------------------------------------------------Stack -[2]Function Body ABC Line 3 |- ABC_PARAM (NUMBER)= 10 |- V_TOTAL (NUMBER)= |- V_NUM3 (NUMBER)= |- V_NUM6 (NUMBER)= ----------------------------------------------------------------

Change the stack value of v_num6 to its correct value. |- V_NUM6 (NUMBER)=6 9 Continue to step through the ABC function using the Step Into button.

Verify the stack values for the v_total variable. At the end of the ABC function, use the Step Into button to return to the XYZ procedure. 00003 v_results :=ABC(10) =>004 v_results := v_results + xyz_param; 00005 MESSAGE(’The results are:’||TO_CHAR(v_results));

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 14-23

Lesson 14: Debugging Triggers ......................................................................................................................................................

Corrected Code FUNCTION abc (abc_param IN NUMBER) RETURN NUMBER IS v_total NUMBER := 0; v_num3 NUMBER := 3; v_num6 NUMBER := 6; /*-- changed value to 6 */ BEGIN v_total := v_num3 * v_num6; v_total := v_total + abc_param; RETURN v_total; END abc;

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 14-24 Oracle Forms Developer: Build Internet Applications I

Debugging Triggers ......................................................................................................................................................

Debugger: Changing the Code and Rerunning 10 Go back into the ABC function in Form Builder. Change the value assigned to v_num6 from 8 to 6. Rerun the form without the Debugger on. The correct result is displayed. FUNCTION abc (abc_param IN NUMBER) RETURN NUMBER IS v_total NUMBER := 0; v_num3 NUMBER := 3; v_num6 NUMBER := 6; /*-- corrected value is 6 */ BEGIN v_total := v_num3 * v_num6; v_total := v_total + abc_param; RETURN v_total; END abc;

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 14-25

Lesson 14: Debugging Triggers ......................................................................................................................................................

Summary •

To debug a form: Use the Run Form Debug button, and set breakpoints.



Debug commands can be entered in the Interpreter pane or by using buttons.

• •

Set breakpoints to invoke the Debugger. Break and Debug triggers are available to program Debug Actions on events in the form.

Copyright  Oracle Corporation, 2000. All rights reserved.

...................................................................................................................................................... 14-26 Oracle Forms Developer: Build Internet Applications I

Summary ......................................................................................................................................................

Summary •

• • •

To debug a form, follow these steps: a Use the Run Form Debug button (compiles and runs form automatically). b Set breakpoints. Debug commands can be entered in the Interpreter pane or by using buttons. Set breakpoints to invoke the Debugger. Break and Debug triggers are available to program Debug Actions on events in the form.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 14-27

Lesson 14: Debugging Triggers ......................................................................................................................................................

Practice 14 Overview

This practice covers using the Debugger to help solve problems at run time.

Copyright  Oracle Corporation, 2000. All rights reserved.

Note For solutions to this practice, see Practice 14 in Appendix A, “Practice Solutions.”

...................................................................................................................................................... 14-28 Oracle Forms Developer: Build Internet Applications I

Practice 14 Overview ......................................................................................................................................................

Practice 14 Overview In this practice, you will create a generic procedure for the LOV in the CUSTGXX form, and you will run this module in Debug mode and step through the code to monitor its progress. Use the Debugger to help solve problems at run time.

...................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I 14-29

Lesson 14: Debugging Triggers ......................................................................................................................................................

Practice 14 1 Open your CUSTGXX.FMB file. In this form, create a procedure that is

called List_Of_Values. Import code from the pr14_1.txt file: PROCEDURE list_of_values(p_lov in VARCHAR2,p_text in VARCHAR2) IS v_lov BOOLEAN; BEGIN v_lov:= SHOW_LOV(p_lov); IF v_lov THEN MESSAGE(’You have just selected a ’||p_text); ELSE MESSAGE(’You have just cancelled the List of Values’); END IF; END; 2 Modify the When-Button-Pressed trigger for

CONTROL.Sales_Lov_Button in order to call this procedure. When-Button-Pressed on CONTROL.Sales_Lov_Button LIST_OF_VALUES(’SALES_REP_LOV’, ’Sales Representative’); 3 Compile and run your form in Debug mode. Set a breakpoint in one of

your triggers, and investigate the call stack. Try stepping through the code to monitor its progress.

...................................................................................................................................................... 14-30 Oracle Forms Developer: Build Internet Applications I