Ora

What is a Stacked Canvas in Oracle Forms?

Published in Oracle Forms UI Elements 5 mins read

A stacked canvas in Oracle Forms is a specialized display area designed to pop up information temporarily, in front of the content canvas, providing dynamic and interactive elements within a form. It acts as an overlay, allowing developers to present additional details, prompts, or lookup windows without navigating away from the primary data entry screen.

Understanding Canvases in Oracle Forms

In Oracle Forms, canvases are the visual display areas where items (such as text fields, buttons, and lists) are placed. They are fundamental to the user interface, defining what the user sees and interacts with. There are several types of canvases, each serving a distinct purpose:

  • Content Canvas: The main display area for a window, typically showing the primary data blocks.
  • Stacked Canvas: Overlays other canvases, usually for temporary information.
  • Tab Canvas: Organizes items into multiple tabbed pages.
  • Toolbar Canvas: Used for buttons and icons that provide quick access to form functions.

The Role of a Stacked Canvas

The primary function of a stacked canvas is to enhance user experience by presenting contextual or supplementary information dynamically. You usually display a stacked canvas based on a button press or some other activity by the user, such as clicking a "Details" button or selecting a record. At some point, it is dismissed, so the user can again see all of the content canvas. This allows for a clean, uncluttered main interface while providing rich interactivity.

Key Characteristics

  • Overlaying Other Canvases: A stacked canvas can be positioned anywhere within its associated window, potentially covering parts of a content canvas or other stacked canvases.
  • Dynamic Visibility: Unlike content canvases which are usually visible by default, stacked canvases are typically hidden and explicitly shown or hidden using PL/SQL built-in procedures. This makes them ideal for temporary displays.
  • Association with Windows: Each canvas, including stacked canvases, must be associated with a window. When the window is opened, the associated canvases are loaded, though stacked canvases remain hidden until explicitly displayed.

Common Use Cases and Examples

Stacked canvases are incredibly versatile and are used in a variety of scenarios to improve application usability:

  • Lookup Windows: Displaying a list of values (LOV) for selection, such as a customer list when entering an order.
  • Detail Screens: Showing detailed information about a selected record from a master-detail block without opening a new form or window.
  • Confirmation Dialogs: Presenting "Are you sure?" messages before committing an action.
  • Data Entry Prompts: Guiding users through multi-step data entry processes or asking for additional input.
  • Information Panels: Displaying help text or specific instructions relevant to the current field or context.
  • Error/Warning Messages: Providing rich, user-friendly feedback instead of simple alert boxes.

Example Scenario

Imagine an order entry form where you select a product. Instead of opening a new window to see product details, a small stacked canvas might pop up showing the product description, current stock, and unit price as soon as a product ID is entered. This canvas disappears when the user clicks "OK" or moves focus away.

Implementing Stacked Canvases

Implementing a stacked canvas involves defining it in the Oracle Forms Builder and then controlling its visibility programmatically.

Creating a Stacked Canvas

  1. Open Forms Builder: Navigate to the Canvases node in the Object Navigator.
  2. Create New Canvas: Right-click and select "Create."
  3. Set Canvas Type: In the Property Palette, set the Canvas Type property to Stacked.
  4. Associate with Window: Ensure the Window property is set to the main window where it will appear.
  5. Place Items: Drag and drop items (text fields, buttons, etc.) from data blocks onto the stacked canvas.
  6. Set Size and Position: Adjust the Width, Height, X Position, and Y Position properties to control where the canvas appears within its window.

Controlling Visibility with PL/SQL

The visibility of a stacked canvas is controlled using Oracle Forms built-in procedures:

  • SHOW_VIEW: Makes a canvas visible.
  • HIDE_VIEW: Hides a canvas.
-- Example: Showing a stacked canvas named 'DETAIL_CANVAS'
PROCEDURE show_details IS
BEGIN
    GO_ITEM('BLOCK_NAME.ITEM_ON_STACKED_CANVAS'); -- Optional: Set focus to an item on the canvas
    SHOW_VIEW('DETAIL_CANVAS');
END;

-- Example: Hiding the stacked canvas
PROCEDURE hide_details IS
BEGIN
    HIDE_VIEW('DETAIL_CANVAS');
    GO_ITEM('MAIN_BLOCK.MAIN_ITEM'); -- Return focus to the content canvas
END;

These procedures are typically called from triggers, such as a WHEN-BUTTON-PRESSED trigger on a "Lookup" button or a WHEN-VALIDATE-ITEM trigger when a field requires additional input.

Design Considerations

  • Positioning: Carefully choose the X and Y coordinates to ensure the stacked canvas appears logically and doesn't obscure critical information.
  • Size: Keep stacked canvases concise. They are for temporary information, so avoid making them too large or complex.
  • Modal Behavior: Although not strictly modal by default, you can simulate modal behavior by disabling other items/blocks or setting the window's Modal property if the stacked canvas is the sole content of a new window.
  • Focus Management: Use GO_ITEM to move the cursor to an appropriate item on the stacked canvas when it appears and back to the main canvas when it's dismissed.
  • Block Association: Items on a stacked canvas can belong to any data block, not just the one currently displayed on the content canvas.

Key Differences: Stacked vs. Content Canvas

Understanding the distinction between stacked and content canvases is crucial for effective Oracle Forms development:

Feature Content Canvas Stacked Canvas
Purpose Primary display for main data blocks and forms. Temporary display for supplementary or dynamic info.
Visibility Typically visible when its window is open. Hidden by default, shown/hidden programmatically.
Interaction Main user interaction and data entry area. Overlays main area; used for specific, temporary tasks.
Persistence Remains visible as long as the window is open. Appears and disappears as needed.
Overlaying Cannot overlay other canvases within the same window (unless a stacked canvas is on top). Can overlay content canvases and other stacked canvases.