Pages

Sunday, 1 April 2018

Creating Oracle Forms Menus





In this tutorial, you learn how to develop your own menu modules to replace the Forms default menu. You also learn how to enhance your applications by including menu toolbars and pop-up menus. Finally you learn how to modify the Forms default menu.


Approximately 30 minutes.


This tutorial is aimed at Oracle Forms developers who wish to broaden their skills with the tool, enabling them to create more user-friendly applications. You learn how you can improve the usability of Forms applications by adding custom menus.


In this tutorial, you design a custom menu with very basic commands to use with an order entry application. You also provide a context-sensitive popup menu for a text item.


The following is a list of software requirements:

·                          Oracle Forms Builder

·                          Oracle database

·                          Application server compatible with Forms Builder

This tutorial is not specific to a particular version of Forms. However, it was developed using Oracle Forms 11g 11.1.1.4, Oracle WebLogic Server 10.3.4, and Oracle database 1111.2.0.1.


Before starting this tutorial, you should perform the following setup steps::

·                          Download the file MenuOBE.zip and unzip it to the directory of your choice.

·                          Ensure that the directory where you unzipped the file is included in your FORMS_PATH environment variable (set in default.env or other environment file that you use for your application). To see how to set environment variables for Forms Runtime, see the deployment guide for the version of Forms that you are using, such as Oracle Fusion Middleware Forms Services Deployment Guide
11g Release 1
.

·                          Open a command window and navigate to the directory where you unzipped the file.

·                          Run SQL*Plus and log into your database as the SYSTEM user.

·                          Run the script create_user.sql to create the summit user with the password oracle.

·                          In SQL*Plus, connect to your database as the summit user.

·                          Run the script create_schema.sql to create database objects for the user summit.

·                          Log out of SQL*Plus and exit the command window.


menu module is a hierarchically-structured object that provides a quick and easy method for operating your Forms application. Like the form module, the menu module is one of the main components of an application.

Each menu module is displayed as a pull-down menu that provides a set of options appearing horizontally under the application window title. Each option can represent a submenu or an action. Selecting a submenu displays a vertical list; selecting an action executes the action. An example of a menu for a running form looks like this:

http://www.oracle.com/webfolder/technetwork/tutorials/obe/forms/11g/formsmenuscreate/images/t1intro.gif

The main menu appears horizontally in the menu bar above the form and below the window title. It contains options, typically individual menus, which are displayed vertically as shown.

Inidividual menus can contain submenus and/or menu items that appear to the right of the selected individual menu. Menu items are the options that perform programmed actions.

Menu modules can optionally display a toolbar in either a horizontal or vertical orientation. A menu toolbar is a set of iconified buttons that represent menu items.

To create a menu module, perform the following steps:

1 .
In the Object Navigator of Oracle Forms Builder, select the Menus node and click Create.:
Screenshot for Step
2 .
The menu module is created as a separate module in Forms Builder. Select the newly-created menu module.
Screenshot for Step
3 .
Click the menu module again so that the name is highlighted in blue. This enables you to easily change the name of the menu module.
Screenshot for Step
4 .
Enter a new name for the module; for example, enter the name SUMMIT_MENU.
Screenshot for Step
5 .
Click Save to save the menu module. Save it to the same directory where your forms are located (the one where you unzipped the setup files.) The menu is saved with a .mmb file extension.
Screenshot for Step


The Menu Editor is a graphical design facility for laying out, modifying, and viewing menu modules and their objects. You can use the Menu Editor to carry out all of your menu design work.

http://www.oracle.com/webfolder/technetwork/tutorials/obe/forms/11g/formsmenuscreate/images/t2intro.gif

As shown above, the Menu Editor provides the following tools:

Tool
Function
Display Menu
Determines the highest level menu that the Menu Editor displays. (Choose from all the menus in your menu module.)
Create Down
Creates a new menu item below the currently active one.
Create Right
Creates a new menu item to the right of the currently active one.
Switch Orientation
Changes display of the top-level menu vertically or horizontally

To use the Menu Editor to create a basic structure for your menu, perform the following steps:

1 .
With the SUMMIT_MENU module selected, perform one of the following actions to invoke the Menu Editor:
·                Double-click the icon to the left of the module
·                Right-click the module and select Menu Editor
·                Select Tools > Menu Editor from the Forms Builder menu
Screenshot for Step
2 .
When you invoke the Menu Editor, it automatically creates the main menu and one menu item. The main menu is the menu whose items, which can be menu items or submenus, show in the menu bar when you run a form.
In the Object Navigator, change the name of the main menu to MAIN_MENU in the same way that you changed the name of the menu module.
Screenshot for Step
3 .
In the Object Navigator, change the name of the menu item to File.
Screenshot for Step
4 .
Note that the item's display label in the Menu Editor remains the same.
The label is the text that is displayed for the menu item at run time. The label may differ from the name. You use the name programmatically, and it must follow PL/SQL naming conventions.
Change the label of the menu item by double-clicking <New_Item> in the Menu Editor and typing the new label ofFile.
Screenshot for Step
5 .
Create two menu items under File. In the Menu Editor, select File, then click Create Down twice.
Screenshot for Step
6 .
In the Menu Editor, relabel the menu items to Save and Exit.
Screenshot for Step
Note that creating menu items under the File object creates a FILE_MENU object as a menu with two items under it. Also, when you relabel the items in the Menu Editor, the names of the items, as shown in the Object Navigator, also change.
7 .
Create another submenu of the main menu and label it Edit by performing the following steps:
·                In the Menu Editor, select the File node.
·                Click Create Right.
·                Relabel the new menu Edit.
Screenshot for Step
8 .
In a similar fashion to the way you created the File menu items, create two items for the Edit menu labeled Copyand Paste.
Screenshot for Step
9 .
You can also use the Object Navigator to add a menu item.
Under the Edit_Menu in the Object Navigator, select the Items node and click Create.
Screenshot for Step
10 .
In the same way as you did with other items, relabel the new item in the Menu Editor with the label Cut, which also renames it in the Object Navigator.
Screenshot for Step


So far you have created a basic structure and layout for the menu, but the menu items have no functionality. The kind of functionality a menu item has depends upon its type. In addition to the default plain menu items, Forms supports four types of special menu items. The menu types with their descriptions and functionality are as follows:

Menu Item Type
Description
Functionality
Plain
A standard text menu item ( the default menu item type that you have created so far)
Defined by PL/SQL
Check
A menu item that has two possible states.
Defined by PL/SQL
Radio
A set of mutually exclusive buttons, each representing a different action
Defined by PL/SQL
Magic
A menu item with predefined functionality
Usually predefined
Separator
A separating horizontal line for grouping menu items
None

The five menu item types appear at runtime as shown below

http://www.oracle.com/webfolder/technetwork/tutorials/obe/forms/11g/formsmenuscreate/images/t3intro.gif

Magic items provide a way to quickly create menu items for standard functions available in most GUI applications.

Some magic items include default functionality. For example, the Cut item is automatically enabled or disabled depending on whether text or image elements have been selected. Invoking the Cut command deletes the selected element and places it on the clipboard. If you create a Cut magic item, Forms automatically provides an accelerator key and command statement for you.

The following table describes the magic menu item types with their valid command types and indicates whether the item provides default functionality, or whether you must define your own command:

Menu Item Type
Command Type
Default
Functionality
About,
Undo
Any but Menu
No
You must assign a command to perform the desired function.
Clear, Cut. Copy, Paste
Null
Yes
These items perform the default operations indicated by their names.
Help
Menu
No
You must define the submenu to be called by the Help item, and you must assign commands to the items on that submenu.
Quit
Null
Yes
The Quit item prompts the end user to save changes (if any) and exits the form.
Window
Null or Menu
Yes
The Window item invokes a default submenu that lists all open windows. End users can activate a window by selecting it from the submenu. If you define your own submenu to be invoked by the Window item, Forms combines its items with the list of open windows and creates a single submenu. Item order on the combined submenu is undefined.

In this section, you modify the menu type of some of the menu items and define their functionality by performing the following steps:

1 .
The menu items in the File menu are Plain items, so you need to add PL/SQL code to define the functionality.
To invoke the PL/SQL Editor, double-click the icon to the left of the Save node in the Object Navigator.
Screenshot for Step
2 .
In the PL/SQL Editor, enter the following code and then click Compile PL/SQL code:
DO_KEY('COMMIT_FORM');
Screenshot for Step
If the PL/SQL code compiles correctly, the message in the lower left margin of the PL/SQL editor changes fromModified to Not Modified. If there is a compilation error, a message appears below the code entry window in the editor. 
3 .
In a similar fashion, enter the following code for the Exit menu item:
DO_KEY('EXIT_FORM');
Screenshot for Step
4 .
The items for the Edit menu are Magic items, so you need to change these from the default of Plain. You do this by changing the properties of the menu item.
Open the Property Palette for the Cut menu item by performing one of the following:
·                Double-click the Cut item in the Menu Editor
·                Right-click the Cut item in the Object Navigator and select Property Palette
·                Select the Cut item in either the Object Navigator or the Menu Editor, then select Tools > Property Palette from the Forms menu
Screenshot for Step
5 .
In the Property Palette, select Magic from the Menu Item Type drop-down list.
Screenshot for Step
6 .
In the Property Palette, select Cut from the Magic Item drop-down list.
Screenshot for Step
7 .
In the Property Palette, select Null from the Command Type drop-down list.
Screenshot for Step
8 .
In a similar fashion, modify the properties of the Copy and Paste menu items, changing their Menu Item Type toMagic, their Command Type to Null,and their Magic Item to Copy and Paste respectively.


menu toolbar is a set of iconic buttons that represent individual items from a menu. When you create a custom form menu, you can specify that some or all of its items appear on a menu toolbar. You need to provide icons to represent the associated buttons on the menu toolbar.

If you use the default form menu, Forms Builder attaches a default menu toolbar to your form automatically, as shown in the application pictured below.

http://www.oracle.com/webfolder/technetwork/tutorials/obe/forms/11g/formsmenuscreate/images/t4intro.gif

Menu toolbars allow developers to easily provide toolbar shortcuts to menu commands without duplicating code or effort.

In this section, you add all of the menu items that you have created so far to a horizontal menu toolbar by performing the following steps:.

1 .
Open the Property Palette for the Cut menu item and set Visible in Horizontal Toolbar to Yes, Icon in Menu to Yes, and Icon Filename to cut.
Screenshot for Step
2 .
In a similar fashion, set the properties of the remaining menu items as follows:
Menu Item
Visible in Horizontal Menu
Icon in Menu
Icon Filename
Copy
Yes
Yes
copy
Paste
Yes
Yes
paste
Save
Yes
Yes
save
Exit
Yes
Yes
exit.
Note: The icon filenames point to standard icons that come with Forms. If you are using custom icons, those files would need to be deployed also.


Before you can use your customized menu module, you must:

·                          Create an executable version. The resulting file that you create has the .mmx extension. A menu module executable file is not portable between operating systems, so you first must deploy the .mmb to the platform where you intend to use the menu and then create the .mmx file there.

·                          Attach the menu to a form module. When you attach a customized menu module to a form module, you are effectively replacing the Forms default menu with your own menu module.

To compile the menu into an executable file and attach it to a form for testing, perform the following steps:.

1 .
Compile the menu. To do this from within Forms Builder, select the SUMMIT_MENU node (or any of its subnodes) in the Object Navigator, and then perform one of the following actions:
·                Select Program > Compile Module from the Forms Builder menu
·                Click Compile Module
·                Use the keyboard shortcut (Ctrl-T on Windows)
This creates the .mmx file in the same directory where you have saved the .mmb file.
Screenshot for Step
Note: If you are prompted to log in, use the credentials of the summit user that you created in the setup section.
2 .
To attach the menu to a form, you must modify a property in the form. To do so, first load the form into Forms Builder. Click Open or select File > Open from the Forms menu. Open orders.fmb from the directory where you saved the setup files.
Screenshot for Step
3 .
Double-click the form module node (ORDERS) to invoke its Property Palette, and change the form's Menu Module property from default&smartbar to summit_menu, then click Save to save the modified form.
Screenshot for Step
Note: As long as the .mmx file is in a directory specified by FORMS_PATH in your environment file, you do not need to specify the complete path to the menu.
4 .
Ensure that the application server is running. For example, if you are using Forms 11g, ensure that the WLS_FORMS managed server is started. In earlier Forms versions, ensure that you have started OC4J.
After starting the application server, click Run Form.
Screenshot for Step
5 .
The form runs with the menu that you defined. You can experiment with the menu's functionality as desired, then click Exit to exit the form.
Screenshot for Step


Pop-up menus are context-sensitive menus. You attach pop-up menus to an item or canvas and display them by right-clicking on that item or canvas. Pop-up menus enable end users to quickly access common functions and commands.

Pop-up menus are objects in the Object Navigator that belong to a form module (similar to alerts, blocks, canvases and so on), as opposed to form menus, which belong to a separate menu module.

Items on a pop-up menu should be contextual to the menu's associated objects. For example, you would not include text-editing items on the pop-up menu for a two-digit numeric text item. However, you might include such items on the pop-up menu for a multiline text item.

To implement and test a pop-up menu, perform the following steps:.

1 .
In the same way as you opened the Orders form, open customers.fmb, then select the Popup Menus node and click Create.
Screenshot for Step
2 .
Rename the new pop-up menu EDIT_MENU.
Screenshot for Step
3 .
Double-click the icon to the left of EDIT_MENU to invoke the menu editor, then click Create Down twice.
Screenshot for Step
4 .
In the Menu Editor, relabel the items CutCopy, and Paste, which also renames them in the Object Navigator.
Screenshot for Step
5 .
Set the menu item properties as you did for the magic items in the SUMMIT_MENU menu that you defined earlier.
Screenshot for Step
6 .
In the Object Navigator expand the nodes Data BlocksS_CUSTOMER, and Items, select the COMMENTS item, and in the Property Palette select EDIT_MENU from the Popup Menu drop-down list.
Screenshot for Step
7 .
Save and run the Customers form. Click the Credit Rating tab and highlight some text in the Comments field. Right-click the text to invoke the pop-up menu that you have defined.
Screenshot for Step
When you have finished experimenting with the functionality of the pop-up menu, exit the form and close the browser window.


The Forms default menu is not a separate menu module, but is built into every form module. The default menu includes standard commands for editing, navigating, and database interaction, such as Action > Save.

When you build a form module, it automatically uses the default menu with a toolbar, as designated by the form's Menu Module property,DEFAULT&SMARTBAR. If you wanted the default menu without the toolbar, you could change this to simply DEFAULT.

The default menu is internal to Oracle Forms Developer. However you can replace the default menu with a custom menu as you did previously in this tutorial. A custom menu that replicates the Forms default menu is included with Forms Demos that you can download from Oracle Technology Network, such as the11g Forms DemosIn this demo pack there are two menu files: menudef_10g.mmb that includes default menu commands, and menudefs_10g.mmb that includes the commands and a toolbar. These files are also included in the setup files for this tutorial. Note that these menus include some obsolete built-ins; you work around these in this section.

The Customers form uses the Forms default menu, but you want to add a menu item to that menu to open the Orders form. To make this modification to the default menu, perform the following steps:.

1 .
In Forms Builder, open menudefs_10g.fmb.
Screenshot for Step
2 .
Rename the menu CUSTOMERS_MENU.
Screenshot for Step
3 .
Select File > Save As and save the menu as customers.mmb.
Screenshot for Step
4 .
Open the Menu Editor for the Customers_menu by double-clicking the icon to the left of the CUSTOMERS_MENUnode in the Object Navigator..
Screenshot for Step
5 .
In the Menu Editor, select the Field submenu and click Create Right, then relabel the new submenu Forms.
Screenshot for Step
6 .
In the Menu Editor, select the new Forms node and click Create Down, then relabel the new submenu Show Orders.
Screenshot for Step
7 .
Double-click the Show Orders node in the Menu Editor to open its Property Palette, click More in the Menu Item Code value, and enter the following code in the PL/SQL editor:
:global.customer_id := NAME_IN('s_customer.id');
OPEN_FORM('orders');
Screenshot for Step|
8 .
To work around the fact that the provided menu file contains obsolete built-ins, add two menu procedures by selecting the Program Units node in the Object Navigator for the Customers_menu module and then clickingCreate. Name the procedures DISABLE_ITEM and ENABLE_ITEM, with the following code:
PROCEDURE disable_item (menu_name VARCHAR2, menu_item VARCHAR2) IS
  item_to_disable VARCHAR2(50) := menu_name ||'.'|| menu_item;
BEGIN
  SET_MENU_ITEM_PROPERTY(item_to_disable,ENABLED,PROPERTY_FALSE);
END;
PROCEDURE enable_item (menu_name VARCHAR2, menu_item VARCHAR2) IS
  item_to_enable VARCHAR2(50) := menu_name ||'.'|| menu_item;
BEGIN
  SET_MENU_ITEM_PROPERTY(item_to_enable,ENABLED,PROPERTY_TRUE);
END;
9 .
Save and compile the Customers_menu menu and then attach the menu to the Customers form by opening its Property Palette and then setting its Menu Module property to customers.
Screenshot for Step
10 .
Run the Customers form to test the menu functionality. You should be able to open the orders for the customer by using the menu (Forms > Show Orders).
Screenshot for Step
Close the forms and the browser window when you are finished.









Defining and Viewing BLOB Data in Oracle Application Express 3.1

Purpose

This tutorial shows you how to create a report and form that inserts and views BLOB data in the database using Oracle Application Express 3.1.

Time to Complete

Approximately 30 minutes

Topics

This tutorial covers the following topics:

http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/bullet.gif
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/bullet.gif
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/bullet.gif
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/bullet.gif
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/bullet.gif
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/bullet.gif
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/bullet.gif
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/bullet.gif

Overview

Declarative BLOB support enable files to be declaratively uploaded in forms, and downloaded or displayed using reports. BLOB display and download can also be authored procedurally using PL/SQL. For further information, click on help and search on BLOB.

To get more information about the 3.1 New Features, click here.

This tutorial shows you how to add BLOB data to your table and then use it in a report and form.



Prerequisites

Before you perform this tutorial, you should:

1.
Install Oracle Database 9.2 or above.
2.
Download and Configure Oracle Application Express 3.1.
3.
Download the OEHR Sample Objects Packaged Application here and import it into your Oracle Application Express 3.1 instance.
4.
Download and unzip the blob.zip file which contains a script to modify the OEHR_EMPLOYEES with BLOB column information.
5.
To perform this tutorial, you need to perform the Building and Customizing an Interactive Report in Oracle Application Express 3.1 tutorial. Alternatively, you can import the OBE New Features application as a packaged application in Application Express. Download and unzip the apexnf.zip file and import the irrobe_packagedapp.sql packaged application file.

Note: The application numbers and page numbers may differ slightly from the screenshots.





Altering the Table to Add BLOB Data

You need to add the BLOB column, PHOTO, as well as a column for MIMETYPE, FILENAME and LAST_UPDATE_DATE in the OEHR_EMPLOYEES table. Perform the following steps:

1.
You first need to define the BLOB column in your table. In this case, you will add a PHOTO column to the OEHR_EMPLOYEES table. In addition, you will create a MIMETYPE, FILENAME and LAST_UPDATE_DATE column so that you can store specific attributes about the photo and view it in different ways. Navigate to SQL Workshop >SQL Script.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blob01.gif
2.
Click Upload.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blob02.gif
3.
Select the addblob.sql file in the directory where you downloaded and unzipped the files from the prerequisites. Enter a name in the name field and click Upload.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blob03.gif
4.
Select the uploaded file.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blob04.gif
5.
Click Run.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blob05.gif
6.
At the confirmation window, click Run.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blob06.gif
7.
Your script was submitted to be executed. Click the View Results icon.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blob07.gif
8.
The table was altered successfully and the PHOTO BLOB column, MIMETYPE, FILENAME and LAST_UPDATE_DATE. Click the Application Builder tab.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blob08.gif


Creating a Form with a Report

In order to load and view BLOB data, you need to create a form with a report. Perform the following steps:

1.
Navigate to your New Features Application page. Click Create Page.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blob09.gif
2.
Click the Form page type.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blob10.gif
3.
Click Form on a Table with Report.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blob11.gif
4.
Click Next.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blob12.gif
5.
Select or enter the OEHR_EMPLOYEES table and click Next.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blob13.gif
6.
Select Classic for Implementation and enter Page Name and Region Title Maintain Employee Information and click Next.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blob14.gif
7.
Accept the default and Click Next.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blob15.gif
8.
For the report, you want to select FIRST_NAME, LAST_NAME, EMAIL and PHOTO from the list of columns and clickNext.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blob15a.gif
9.
Accept the default and click Next.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blob15b.gif
10.
Enter Maintain Employee Details for Page Name and Region Title and click Next.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blob15c.gif
11.
Accept the default and click Next.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blob16.gif
12.
Accept the default and click Next.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blob17.gif
13.
Select all the columns except MIMETYPE, FILENAME and LAST_UPDATE_DATE and click Next. Note: The columns you did not include will automatically be populated when you add a PHOTO.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blob18.gif
14.
Accept the default and click Next.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blob19.gif
15.
Click Finish.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blob21.gif
16.
Click Run Page.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blob22.gif
17.
The report is displayed. Currently, there is no data in the Photo column since you haven't uploaded any BLOB files yet. Click on the Edit icon for an employee.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blob23.gif
18.
The form is displayed. You can add a photo. Click Browse... Select your file, in this case dog.gif and click Open.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blob30.gif
19.
Click Apply Changes.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blob30a.gif
20.
Notice that the Report now has a Download link for the record you added the Photo to. Click the Download link.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blob30b.gif
21.
The download link produces a window that allows you to download a file but it doesn't say the name of the file or where it will be copied to. In the next section, you examine how to specify the parameters associated with the Photo column in a form and report.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blob30c.gif


Updating and Viewing BLOB Data in a Form

You can change the way that the BLOB Data is displayed, either inline or as an attachment. Perform the following steps:

1.
Click the View icon for the employee you added the photo previously.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobform01.gif
2.
Notice that you automatically see a download link. Click the Edit Page link in the developer toolbar.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobform02.gif
3.
Under Items, select the P<#>_PHOTO link.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobform03.gif
4.
Select the Source tab.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobform04.gif
5.
Click the BLOB Download Format Mask link.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobform05.gif
6.
In order for the information to be read from the database, enter MIMETYPE for MIMETYPE, FILENAME for FILENAME and LAST_UPDATE_DATE for BLOB Last Updated Column. Select Attachment for the Content Disposition and leave the default Download Link Text at Download and click Apply.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobform06.gif
7.
Notice how the Source Value or Expression has changed based on the input you just provided. Click Apply Changes.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobform07.gif
8.
Click Run Page.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobform08.gif
9.
In order for the MIMETYPE, FILENAME and LAST_UPDATE_DATE to be populated in the database, you need to reupload the file. Click Browse... select the file, in this case dog.gif, and click Open.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobform09.gif
10.
Click Apply Changes.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobform10.gif
11.
Select the Edit icon next to row that contains the Download link.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobform11.gif
12.
Click the Download link.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobform12.gif
13.
Notice that the file name is now specified on the dialogue. It also is opening the file as an attachment using a program identified from the MIMETYPE. Click OK.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobform13.gif
14.
The file is open in a separate window. Close the window.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobform14.gif
15.
You will change the Content Disposition to see what happens when you select inline instead of attachment. ClickEdit Page.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobform15.gif
16.
Under Items, click P<#>_PHOTO.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobform16.gif
17.
Under Source, click the BLOB Download Format Mask link.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobform17.gif
18.
Change the Content Disposition to Inline and click Apply.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobform18.gif
19.
Click Apply Changes.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobform19.gif
20.
Click Run Page.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobform20.gif
21.
Click the Download link.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobform21.gif
22.
Notice now that the image is shown within the browser (inline). To return to the form, click the Back button in your browser.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobform22.gif
23.
In the next section, you make the necessary changes to display the image from within the report. Click Apply Changes.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobform23.gif


Viewing BLOB Data in a Report

In this section, you make the necessary changes to view a BLOB column in different ways within a report. Perform the following steps:

1.
Click the Edit Page link in the developer toolbar.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobrpt01.gif
2.
Under Regions, select the Report link.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobrpt02.gif
3.
Select the Edit icon in front of PHOTO.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobrpt03.gif
4.
Under Column Formatting, notice that some of the parameters for the BLOB are already displayed. Select the BLOB Download Format Mask link.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobrpt04.gif
5.
Enter MIMETYPE for MIMETYPE, FILENAME for FILENAME and LAST_UPDATE_DATE for BLOB Last Updated Column. Notice that Content Disposition is set to Inline. Click Apply.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobrpt05.gif
6.
Click Apply Changes.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobrpt06.gif
7.
Click Run Page.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobrpt07.gif
8.
Select the Download link.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobrpt08.gif
9.
Notice that the image is displayed inline in the browser. Click the Back button in your browser to return to the report. Note that the attachment content disposition works the same as in the form so you will not examine that option again.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobrpt09.gif
10.
Click Edit Page.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobrpt10.gif
11.
Under Regions, select the Report link.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobrpt11.gif
12.
Select the Edit icon for PHOTO.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobrpt12.gif
13.
Under Column Formatting, select the BLOB Download Format Mask link.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobrpt13.gif
14.
Change the Format Mask to IMAGE and click Apply.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobrpt14.gif
15.
Click Apply Changes.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobrpt15.gif
16.
Click Run Page.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobrpt16.gif
17.
Notice this time the image is inserted directly into the report itself.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/blobrpt17.gif
Note: To modify the display attributes of the image (i.e. to make it smaller), you need to use the programmic way of including images. See the documentation at (http://download.oracle.com/docs/cd/E10513_01/doc/appdev.310/e10499/api.htm#CHDICGDA)



Summary

In this tutorial, you learned how to:

http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/bullet.gif
Alter a table to add BLOB data
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/bullet.gif
Create a form with a report that contains the BLOB column
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/images/bullet.gif
View BLOB data in a form and report


No comments:

Post a Comment