developer 6.0 tutorial

Page 1

Tutorial Developed at the College of Business, Florida State University. Page 1

Developer 6.0 Form Builder Tutorial IInnttrroodduuccttiioonn Developer 6.0 Forms is a visual application development environment. Application developers use it to create easy-to-use enterprise client-server applications that allow end-users to interact with an Oracle8i database. Coomppoonneennttss ooff Deevv eellooppeerr 66..00 Developer 6.0 Forms is just one of the tools in the Oracle Developer 6.0 toolkit. Other tools included are: • Developer 6.0 Reports: an application development tool that allows the generation and formatting of complex reports. • Developer 6.0 Graphics: a multimedia tool that allows graphical images to be dynamically linked to a data source. • Developer 6.0 Procedure Builder: allows you to create and manage program units separately from the other application tools. Together, the Developer 6.0 tools provide a comprehensive integrated application development environment. In addition, all Developer 6.0 tools operate in a similar manner and have a similar interface. Because of this, knowing how to work with one allows you to work with all. Frroonntt--eenndd aanndd Baacckk --eenndd Developer 6.0 application development tools combine to form the database “front-end”, while the Oracle8i Relational Database Management System software is known as the database “backend”. Prreevv iioouuss kknnoowlleeddggee nneeeeddss No previous programming knowledge is required to use a Forms application. Form uses SQL and PL/SQL to interact with the database back-end, but the code is hidden from the user. However, a Developer 6.0 Forms developer should have good knowledge of SQL and PL/SQL. Evv eenntt--ddrriivv eenn eennvv iirroonnmeenntt Developer 6.0 Forms is an event-driven environment. In an event-driven environment the enduser is in control of the application. In the Forms environment, event-driven functionality is achieved by means of PL/SQL code. For example, you can write PL/SQL code that executes when the end-user clicks on the associated button. Tutorial Developed at the College of Business, Florida State University. Page 2


Coomppoonneennttss ooff Deevv eellooppeerr 66..00 Foorrmss Developer 6.0 Forms consists of three executable components, as follows: • Designer: used to build a forms application. It consists of a number of tools that allow you to create form modules, add and manipulate text and graphical objects, and write eventdriven code • Generate: used to create a runtime executable. You can use the Generate component to compile a completed application and create a runtime file • Runform: used to execute an application Moodduulleess A Developer 6.0 Forms application is made up of high-level objects called modules. In general, a module is defined as a collection of related objects that provides functionality in an application. There are three types of modules in Developer 6.0 Forms applications: • Form (a collection of graphical and other logical objects that define the application interface) • Menu ( a collection of objects that help the end-user to operate the application interface) • Library ( a collection of PL/SQL code objects that can be called by other modules) An application can have many modules, and each module can have many objects. Obbjjeeccttss tthhaatt maakk ee uupp aa ffoorrm moodduullee Lets look at some of the objects that make up a form module: A window object is a visual screen displayed in an application. A canvas object is the visual template used to build the application. In other words, it is the background on which the interface is created. At runtime, you look at a canvas through a window. A block is a logical group of objects. A base block can hold objects that correspond to a base table, while a control block can hold non-database objects. An item can represent a single column in a base table. An item can also be a graphical object like a button or checkbox. A trigger is a block of executable PL/SQL code that is associated with an object and fires when a predefined event occurs. For example, a trigger fires when a button is clicked. A trigger can also be associated with other objects such as a block or form module. Properties are the attributes of an object. For example, an item such as a button has height, width, name, and label. Other objects such as a block also have properties. Tutorial Developed at the College of Business, Florida State University. Page 3

Forms supports other visual objects which can enhance the appearance and functionality of an


application: - LOV (a List Of Values object can carry out a dynamic base table look-up) - Editor (an editor object can be used to input blocks of text) - Alert (an alert object can be used to display messages and warnings to the end-user) Viissuuaall oorr Loogg iiccaall oobbjjeeccttss Forms objects can be visual or logical. For example, a window is a visual object and a block is a logical object. Hiieerraa rrcchhyy ooff ffoorrmss oobbjjeeccttss Forms objects are hierarchical. This means that some objects are “owned” by other. Visual objects are organized in a visual object hierarchy of window, canvas, and item. An enduser looks through a window at a canvas, and items are displayed at the canvas. Logical objects are organized in a containership hierarchy of form, module, block, and item. A form module “owns” a block and a block “owns” items. An item is part of both the visual and logical hierarchy because it has functional as well as visual attributes. PL/SQL triggers and properties are also part of the containership hierarchy. Prroocceessss ooff ddeevv eellooppiinngg aa bbaassiicc Foorrmss aapppplliiccaattiioonn The process of developing a basic Forms application can be divided into a number of logical steps. 1. A program specification is written to clearly identify what the application should do. 2. Form, menu, and library modules are identified and created. You can think of these as “containers” for the objects that make up an application. 3. A canvas is created. An application may have many canvases. 4. A block is created. A form module as well may have many blocks. 5. Items are created. Items are placed on the canvas and belong to a block. 6. Object properties are set. PL/SQL triggers are coded to give the application its eventdriven functionality. 7. A window is created, through which the end-user will view the canvas. A Developer 6.0 Forms application can have many windows and many canvases. 8. Finally, the application is fully tested, debugged, and documented. And an executable file is generated. The complete application is now ready for release. The default functionality of Developer 6.0 Forms can help you automate many of the steps involved in building an application. Tutorial Developed at the College of Business, Florida State University. Page 4

SSttaarrtt uupp ooff Deevv eellooppeerr 66..00 Foorrm Buuiillddeerr When you start up the Developer 6.0 Form Builder, a welcome screen will appear. You can click


on cancel to show the Object Navigator tool. As your Forms application will need to access a database, a connection must be made to this database. You can connect to the database from the Form Builder by choosing File | Connect. A dialog box will ask you for a username, a password and the name of the database that you want to connect to. Note that if you do not connect, some forms may not compile correctly. This is frequently the reason of compilation errors. Prriinncciippaall ttoooollss ffoorr ccrreeaattiinngg aanndd bbuuiillddiinngg aann aapppplliiccaattiioonn There are several tools you will use to create and build an application. The principal tools are: • Object Navigator • Layout Editor • PL/SQL Editor • Menu Editor • Properties window Deessccrr iippttiioonn ooff tthhee Obbjjeecctt Naavv iiggaattoorr The Object Navigator is a hierarchical filing system that allows you to navigate freely to any object in a Developer 6.0 Forms application. In order to build an application, you must create modules, blocks, and items, and set their properties. There are five top-level nodes in the Navigator. These are: • forms • menus • libraries • built-in packages • database objects All other nodes and objects within an application are indented to indicate that they belong to the top-level nodes. Form, menu and library nodes are the main building nodes for an application. Built-in packages are collections of functions, procedures, and packages provided by Oracle. They provide additional functionality and can be called in a Developer 6.0 Forms application as you need them. Although built-in packages can be used anywhere in the Oracle environment, some are specific to Developer 6.0 Forms. Database objects are objects that are physically stored in the database. For example, tables, views, and stored program units are database objects. Tutorial Developed at the College of Business, Florida State University. Page 5


Each object or node in the Navigator has a blue + or – symbol in front of it that indicates whether it is currently expanded or collapsed. A gray + indicates that a node does not yet contain any lower-level objects. An object that cannot contain any lower-level objects has a bullet symbol displayed. SSttaarrtt uupp ooff tthhee Foorrm Buuiillddeerr When you start up the Form Builder, a form module is automatically created and listed in the Object Navigator. This module is an object itself, but it is also made up of objects. In the list below MODULE1, are objects such as Triggers, Blocks, and Canvas-views. This list is indented under MODULE1 to indicate that these objects belong to this module. Obbjjeecctt Crreeaattiioonn To create an object, you select a node or another object of the type you want to create. You then select Navigator | Create. Alternatively, you can click on the Create icon. When a node does not yet contain any objects, you can create an object of that type by double clicking on the gray + symbol. Ownneerrsshhiipp Viieew aanndd Viissuuaall Viieew You can display modules in the Navigator in two ways: - Ownership view (default) - Visual view The view determines which objects you can see in the Navigator and how they are arranged. Ownership view shows the logical or containership hierarchy of application objects. Visual view shows the visual organization of objects in windows and canvases When the Navigator is in Ownership view, items are listed under the blocks to which they are assigned. In Visual view, items are listed under the canvas on which they are displayed. Reennaamiinngg oobbjjeeccttss Whenever you create an object in the Navigator, it will be assigned a default name, such as CANVAS1 or BLOCK9. To assign a meaningful name to an object, you highlight it in the Object Navigator and click the left mouse button once. The cursor will change to an Ibeam. You then enter the new object name. Tutorial Developed at the College of Business, Florida State University. Page 6

Deessccrr iippttiioonn ooff tthhee Laayyoouutt Eddiittoorr The Layout Editor is used to create and arrange interface items, boilerplate text, and graphics on


canvas. You will use it to create the interface end-users will see when they use your application. There are a number of ways to invoke the Layout Editor: - select Layout Editor from the Tools menu - choose Layout Editor from the popup menu (press the right mouse button to display the popup menu) - Double-click on the object icon for the canvas you want to edit. Crreeaattiinngg oorr sseelleeccttiinngg ccaannvvaass If there are no canvases in the form module, Forms creates a default canvas. If there is only one canvas already created, it will be displayed. If there are several canvases, Forms displays a list of values from which you can select the relevant canvas. To switch to a different canvas from the Layout Editor, you simply chose the required canvas from the Canvas drop-down list. Chhaannggiinngg ccaannvvaass’’ss pprrooppeerrttiieess When you create an item on the canvas, it is automatically assigned to the current block. You can change this by choosing the required block from the Block drop-down list. Canvases are displayed at windows at runtime. You can choose which window a canvas will be displayed in by setting the canvas’s Window property. Deeffiinniittiioonnss ooff iitteemss The objects you will work with on a canvas are either items or boilerplate graphics. Items are the interface controls the end-user will interface with. For example, checkboxes, buttons, and radio groups are items. Each item belongs to a block and is listed under that block in the Object Navigator. Deeffiinniittiioonn ooff Boo iilleerrpp llaattee ggrraapphhiiccss Boilerplate graphics are the lines, text, circles, and images that you can draw or import into the canvas. They are associated with the canvas on which you place them. Boilerplates are not named objects. They do not appear in the Navigator listing, and their properties are not displayed in a properties window. Tutorial Developed at the College of Business, Florida State University. Page 7

PL//SSQL Eddiittoorr The PL/SQL Editor allows you to enter and compile code objects for your Forms application. Code objects include: - event triggers - functions - procedures - packages


- menu item commands - menu startup code PL/SQL code objects provide the event-driven functionality of the Developer 6.0 Forms. To invoke the PL/SQL Editor you can either choose it from the Tools menu, or double-click on the object icon for any code object in the Navigator. Meennuu Eddiittoorr Every form module has a built-in default menu. This provides standard commands for navigation, editing, and database interaction. If a form module is simple, the default menu is usually adequate. However, if you are building more complex applications, you will want to create your own custom menus. You do this by creating a menu module and using the Menu Editor. Prrooppeerrttiieess wiinnddoow All objects in a Forms application have properties. You can set object properties so that objects look and behave as you please, thus enhancing your application design. You can set object properties in the Properties window. You can invoke the properties window by selecting Tools – Properties. Alternatively, you can double-click on an object icon on the Navigator, or double click on an item in the Layout Editor. Once it is open the Properties window displays the properties of whichever object in the Navigator has the focus. Tutorial Developed at the College of Business, Florida State University. Page 8

Geenneerraall Diirreeccttiioonnss ffoorr tthhee Exx eerrcciisseess Initially, you have to start Personal Oracle 8i following the directions provided in the Oracle Center website (http://cob.fsu.edu/ims/oracle/faq.html). Since you are working with Personal Oracle 8i in the computer labs of the College of Business, remember that everything you create remains local (in the specific machine you are working on). Once the computer reboots, everything will be lost. From the Oracle Center website (http://cob.fsu.edu/ims/oracle/tutorial.html), download and save the file needed for working on the following exercises. Assuming that you didn’t change the name of the file from insert.sql (even though the link does not display the actual filename), save the file in your disk. Then, go to: Start _ Programs Oracle Applications Application Development SQL*Plus Once the SQL*Plus program initiates, log-on using ‘scott’ as the user-ID, ‘tiger’ as the


password, and leave the connect string blank. Then, run the insert.sql file from the location where you have it stored, by executing: START <path> insert.sql; where instead of <path>, you should type the actual path where you stored the file. Once the execution of insert.sql is over, you are ready to move on to the exercises. You can close the SQL*Plus window by typing exit and pressing the Enter key. Tutorial Developed at the College of Business, Florida State University. Page 9

Exx eerrcciissee 11 In the first exercise, we will practice in creating a window, a content canvas-view, a default block, then in customizing some of the item attributes, and finally, saving and running the form. By running the insert.sql file, we have created the database tables required for the following exercise. But before we continue, we will create a new directory on our diskette in order to save the forms we will create. Otherwise, computer labs are set up to delete any new files upon start up. Therefore, create a directory called: A:\Labs. Now, launch the Developer 6.0 Form Builder by clicking on the Start button and selecting Programs Oracle Applications Developer 6.0 Form Builder. If this is the first time you launch this application, or you have not changed the default settings, you will be presented with a dialog box that gives you various starting options. Select Use the data Block Wizard, and in the next two windows click Next, (as long as Table or View is selected in the second window). Then click on Browse and provide your username (scott), password (tiger) and the connect string (leave blank) in order to connect. In the next window, select only Current User and Tables, and click OK. Then select table EMP and again, click OK. Click the Select All button and then click Next. In the following screen, select the option “Just create the Data Block” and click Finish. A new form and window are created. You should perform the following: 1. Click on the Windows node in the Object Navigator. Click on the plus sign to expose WINDOW1. 2. Change the name of the new window to EMPLOYEE. Tutorial Developed at the College of Business, Florida State University. Page 10

3. By double clicking the empty box beside the Canvases node, Oracle will create the initial canvas-view and give it an initial name, e.g. CANVAS2. Change its name to the more


meaningful EMPLOYEE. 4. Go to the Tools menu and select Layout Wizard. Click Next in the Welcome Screen, and again Next, since we only have one canvas to choose from. In the next screen, select all the available items from our only Data Block and click Next twice, without making any changes. In the next window select Form and click Next. Give the name Employee, and click on Finish. 5. Save the form in the folder you created before, by pressing CTRL + S, and giving it the name Employee.fmb 6. Press CTRL + R, to run the form. When the form appears, select Execute from the Query menu, and then use the navigation buttons to move between records. Exx eerrcciissee 22 In the second exercise, we will learn what a master-detail relationship is, when to use it, and how to create it. A Master-Detail relationship is an association between two base table blocks; the parent is called a master block, and there is a detail block whose records are associated with the parent’s. In our example, we want the form to contain information about the department in which each employee belongs. Therefore, we will have Emp as the Master Table, and Dept as the Detail Table. This exercise is a continuation of the first exercise. Therefore, we assume that you already have completed exercise 1, saved the form in your disk, and continue working in the form. 1. From the Object Navigator, click on the Data Blocks node. 2. From the Tools menu, invoke the Data Block Wizard and after the welcoming screen request to create a block based on a table or view. Click on Next. 3. Select Dept as the base table for the new block and include all its columns in the block. Click on Next. 4. At this point you will see a new window, that is used to create the Master/Detail relationship. If the Auto-join data blocks option is selected, please deselect it. Generally, this option saves you some steps, but in order to understand the underlying logic, we won’t use it for now. 5. Click the Create Relationship button. The Employee: Data Blocks LOV dialog box appears. 6. Select Emp from the list. After selecting DeptNo from the Master Item drop-down list, you will see the join condition: DEPT.DEPTNO=EMP.DEPTNO.


7. Click Finish to complete your work with Data Block Wizard and invoke the Layout Wizard. 8. After the welcoming screen, accept the selection of the existing canvas as the one where the items of the new block will be created. Click on Next. 9. Select to display all items except for DEPTNO. Click on Next twice. 10. Choose a form layout of the frame for the Department block, and moving to the next screen, set the frame title to “Department”. Without making any other changes, click Finish to complete the creation of the second block. 11. Go to File | Save as to save the form under a different name. Tutorial Developed at the College of Business, Florida State University. Page 11

12. Press CTRL + R, to run the form. When the form appears, select Execute from the Query menu, and then use the navigation buttons to move between records. Exx eerrcciissee 33 As previously, this exercises builds upon the previous ones. We assume that you already saved the outcomes of both exercises one and two in your disk, and continue working on Form Builder. In the third exercise, we will create a menu for our form. 1. While working on the Form Builder, create a new menu module in the Object Navigator by selecting File | New | Menu. 2. Rename the menu module name that you just created to something more meaningful, for example Standard. 3. Save the newly created module to the directory you created in your disk. 4. Launch the Menu Editor by being anywhere inside the hierarchy of the menu module you want to display in the Editor, and selecting Tools | Menu editor from the Navigator Menu. At this point, you will see that the Form Builder creates a new menu called Menu1. 5. Type File over the <New_Item> label. 6. Click the Create Right icon on the toolbar or select Menu | Create Right from the menu. 7. Type “Edit” in the label of the new item. 8. Repeat steps 6 and 7 to create the items Window and Help for the Menu1. At the same time, you will see that the top-level menus we created appear in the Navigator’s object tree. To create submenus: 9. Select the File menu item. 10. Click the Create Down icon on the toolbar or select Menu | Create Down from the menu. 11. Type “New” over the <New_Item> label. 12. Repeat steps 10 and 11 to create items “Open”, “Close”, “Run”, “Print”, and “Exit”. Practice your skills until you create the following:


13. Save your module. 14. Right click on the “Close” item, and from the popup menu select: PL/SQL Editor. 15. Type commit;, click the Compile button and then the Close button. 16. Save the menu. Tutorial Developed at the College of Business, Florida State University. Page 12

Exx eerrcciissee 44 Based on Exercises 1 and 2 of the first Developer 6.0 tutorial handout, create a similar form that includes Department as Master and Employees as Detail. Select the Detail Block appearing in a tabular form, and select the presentation of 6 records (rows) and a Scrollbar. Save it as DEPT_EMP. In a similar manner, and based on exercise 3 of the previous handout, create a menu that includes the following options: Save it in your floppy disk under the name DEPT_ MENU , without including any commands from the PL/SQL Editor. Open the Properties Palette. By default, the property Menu Item Type is set to “Plain” for every menu item you create. Plain items are the type you will encounter the most in the menus you develop. Besides “Plain” and “Separator” (which should be set in order to create a separator line, after you create a menu item with the text ‘separator’), the Property item can be set to “Magic”, “Radio”, and “Check”. When the type is “Magic”, you can assign a built-in command or function to the item such as Cut, Copy, or Paste. Using this information, follow these steps to implement the Items of the Edit menu: 1. Select all the items in the Edit menu. 2. Set their property Menu Item Type to “Magic”, and deselect the items. 3. For each individual item, set the property Magic Item to the setting that corresponds to its name. For example, Magic Item will be “Cut” for the menu item Cut. The advantage of using magic items is that Developer 6.0 Forms will handle the text editing


functionality and decide about its availability. Forms internally will check the context for every situation and turn on or off the appropriate items that can be used in that situation. Tutorial Developed at the College of Business, Florida State University. Page 13

Ussiinngg PL//SSQL iinn Meennuuss Using different PL/SQL commands, you can initiate a variety of actions from your menu items. Some of these actions may correspond to Developer 6.0 Forms built-in procedures. For example, all the menu items in the Data submenu correspond to built-in procedures. More specifically, while being on the Menu Editor, right-click the menu item Data | Insert. In the pop-up menu that will appear, select PL/SQL Editor. In the Editor window, enter the following text: DO_KEY(‘Create_Record’); Similarly, enter the following code for the corresponding menu items: Menu Item Menu Item Code Property File Clear DO_KEY(‘Clear_Form’); File Save DO_KEY(‘Commit_Form’); File Exit DO_KEY(‘Exit_Form’); Data Duplicate Record DO_KEY(‘Duplicate_Record’); Data Duplicate Item DO_KEY(‘Duplicate_Item’); Data Delete DO_KEY(‘Delete_Record’); Data Enter Query DO_KEY(‘Enter_Query’); Data Count Query Hits DO_KEY(‘Count_Query’); Data Execute Query DO_KEY(‘Execute_Query’); For the moment, in the remaining menu items you can place the following line: MESSAGE(‘Feature to be implemented’); Save the menu. Tutorial Developed at the College of Business, Florida State University. Page 14

Attttaacchhiinngg aa Meennuu ttoo aa ffoorrm From the Start button, find the Forms Compiler. Once you start it, you will see the following window: Click on Browse and go to the specific directory in your floppy disk, where you saved the menu that you created before. Select that menu. Provide ‘scott’ as the UserID, ‘tiger’ as the Password, and leave the Database Connecting String blank. Also, change the Module Type from FORM to MENU. Click on OK. In that way, we generated the menu to be used in our forms. The filename will have the extension *.MMX. From the Object Navigator, open the DEPT_EMP form you created in the first part of this handout.


While having selected the Form DEPT_EMP, open the Property Palette from Tools ďƒ ď€ Property Palette. In the property Menu Module, replace what you see with: Dept_Menu Save the form, and then run it to see the result.


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.