Friday, 4 April 2014

APEX Shortcuts Use Case

Recently Martin described APEX Shortcuts, a shared component that I don't often use - and probably even less now.

APEX wizards create them for the delete process in forms, but I thought I'd describe an example of how you might use one for your own needs.

The sole purpose I've used them is to generate HTML text from PL/SQL - often for links to appear near text items. For example, you could use them to

  1. Provide a quick way to clear the text in a field
  2. Populate a date picker with today's date
  3. Generate a list of quick picks, derived from a ref codes table.
The last one is now superceded by a the Dynamic Quick-Picks plug-in.

To show the simplest example, here is how you can add a link to clear an item. First, define the shortcut as some PL/SQL that simply returns some generated HTML - the link that clears the item. Note we can use #CURRENT_ITEM_NAME# to substitute in the relevant item.

Create APEX Shortcuts from Shared Components
Then we refer to the shortcut name in the Post Element Text of the item. Note the "SHORTCUT_NAME" syntax, which should be in uppercase. This renders the shortcut value after the item.
Item property using an APEX shortcut
The final output will differ depending on your theme, but here is a screenshot from my sample app that uses a bare-bones theme 25.
Final runtime result
Relevant documentation can be found here.

What I would like to know is why they're called shortcuts!?
Post a Comment