Using Shortcuts

Use shortcuts to avoid repetitive coding of HTML or PL/SQL functions.

What is a Shortcut?

Use a shortcut to define frequently used code once and then reference it in many places thus reducing code redundancy. For example, you can create a shortcut to define a page control such as a button, HTML text, a PL/SQL procedure, or HTML.

You can use a shortcut within the following locations:

  • The Region Source attribute of regions defined as HTML Text (with shortcuts).

  • Region Header and Footer Text attribute.

  • Item Label attributes, Pre Element Text, Post Element Text, and Default Value attribute.

  • Region Templates attributes.

Referencing a Shortcut

Once you define a shortcut, you can invoke it using specific syntax unique to the location in which the shortcut is used.

You reference shortcuts using the following syntax:

"MY_SHORTCUT"

The shortcut name must be capitalized and enclosed in quotation marks.

Supported Shortcut Types

Oracle Application Express supports six types of shortcuts.

When you create a shortcut you select a shortcut type. Supported shortcut types include:

  • PL/SQL Function Body

  • HTML Text

  • HTML Text with Escaped Special Characters

  • Image

  • Text with JavaScript Escaped Single Quotes

  • Message

  • Message with JavaScript Escaped Special Quotes

Text with JavaScript Escaped Single Quotes

Use this type of shortcut to reference a shortcut inside of a JavaScript literal string. This shortcut defines a text string. When the shortcut is referenced, it escapes the single quotation marks required for JavaScript.

Message

Use this type of shortcut to reference a translatable message at runtime. Since this shortcut does not have a shortcut body, the name of the shortcut must match the corresponding message name. At runtime, the name of the shortcut expands to the text of the translatable message for the current language.

Message with JavaScript Escaped Single Quotes

Use this type of shortcut to reference a shortcut inside of JavaScript literal string and reference a translatable message at runtime.

Defining a Shortcut from Scratch

Define a shortcut on the Shortcuts page.

To define a shortcut:

  1. Navigate to the Shared Components page:
    1. On the Workspace home page, click App Builder.
    2. Select an application.
    3. On the Application home page, click Shared Components.

      The Shared Components page appears.

  2. Under Other Components, select Shortcuts.
  3. Click Create.
  4. For Create Shortcut, select From Scratch and click Next.
  5. On Shortcut Attributes:
    1. Name - Enter the name by which the shortcut will be referenced.
    2. Type - Select a shortcut type. Options include:
      • PL/SQL Function Body

      • HTML Text

      • HTML Text with Escaped Special Characters

      • Image

      • Text with JavaScript Escaped Single Quotes

      • Message

      • Message with JavaScript Escaped Special Quotes

    3. Shortcut - Enter the text of the shortcut. The shortcut must be less then 30,000 characters in length.
    4. Error Text - Enter the text to display if an error should occur during the processing of a shortcut.
    5. Build Option - Select a build option for this component.
  6. Click Create.

    New shortcuts are added to the Shortcuts page (also referred to as the Shortcut repository).

Copying an Existing Shortcuts

Copy existing shortcuts from the Shortcut repository.

To copy an existing shortcut:

  1. Navigate to the Shared Components page:
    1. On the Workspace home page, click App Builder.
    2. Select an application.
    3. On the Application home page, click Shared Components.

      The Shared Components page appears.

  2. Under Other Components, select Shortcuts.
  3. Click Create.
  4. For Create Shortcut, select As a Copy of an Existing Shortcut and click Next.
  5. On Copy From Application, Select the application you want to copy shortcuts from and click Next.
  6. On New Shortcuts: Click Copy Shortcut.
    1. To Name - Enter the new name of the shortcut to be copied.
    2. Copy - Select Yes, No, or Copy and Subscribe.
    3. Click Copy Shortcut.

    New shortcuts are added to the Shortcuts page (also referred to as the Shortcut repository).

Editing Existing Shortcuts

Once you create a shortcut, you can alter it by editing attributes on the Edit Shortcut page.

To edit an existing shortcut:

  1. Navigate to the Shared Components page:
    1. On the Workspace home page, click App Builder.
    2. Select an application.
    3. On the Application home page, click Shared Components.

      The Shared Components page appears.

  2. Under Other Components, select Shortcuts.
  3. Select a shortcut.

    The Edit Shortcut page appears.

  4. Edit the attributes.

    To learn more about an attribute, see field-level Help.

  5. Click Apply Changes.

Accessing Shortcut Reports

View the shortcut Subscription and History reports.

To access shortcut reports:

  1. Navigate to the Shared Components page:
    1. On the Workspace home page, click App Builder.
    2. Select an application.
    3. On the Application home page, click Shared Components.

      The Shared Components page appears.

  2. Under Other Components, select Shortcuts.
  3. Click one of the following tabs:
    • Subscription - Displays the Subscribed Shortcuts page which displays all subscribed shortcuts in your application.

    • History - Display the Shortcut History page which displays a history of recently changed shortcuts by date.

    Note:

    The Subscription and History tabs only appear after you create a shortcut.