Skip to main content

Command Palette

Search for a command to run...

The Power of APEX Template Directives

Updated
The Power of APEX Template Directives
R

Rodrigo is a Senior Oracle Developer at QV Systems. He is an experienced software engineer with emphasis in analysis, design and development of bespoke Oracle applications utilising development tools such as APEX, PL / SQL, jQuery, javaScript, CSS and JSON for a variety of international businesses. Rodrigo speaks regularly at Oracle community events and enjoys creating APEX plugins and writing blogs.

Oracle APEX Template Directives allow us to move data formatting from SQL to HTML, creating easier-to-read queries, improving performance, and reducing the risk of Cross-Site Scripting attacks.

Template Components can be used on any component with the HTML Expression, and we have the following options:

  1. IF: For the IF example we are going to use the DISABLE_FLAG column. If there the column is not null will return Yes else NO.

    Token Modifiers

    | Condition | Directive | | --- | --- | | if_exists_and_true | {if ITEM/} | | if_exists | {if ?ITEM/} | | if_not_exists_or_false | {if !ITEM/} | | if_not_exists | {if !?ITEM/} | | if_not_false | {if =ITEM/} | | if_exists_and_false | {if !=ITEM/} |

  2. CASE: For the CASE we are going to use the GENDER column. When M we will show the fa-male icon and fa-female when the value is F.

  3. LOOP: For the LOOP, the column BADGES contains colon-separated values representing all the badges the user has. We are going to break that into <li> elements and add the fa-trophy icon.

    The code above will return the following:

  4. WITH and APPLY allow us to add predefined template component plugins and use them inside a template component (nested template component) or in HTML Expressions. In the example below, we will use the BADGE template component plugin to show the value of the FULL_NAME column.

    The code above will return the following:

    To help us build the WITH/APPLY and add all the custom attributes for each plugin, Matt Mulvaney created the Template Component With/Apply Generator This tool is very helpful for generating the WITH/APPLY for each plugin

    ##

More from this blog

A

APEX Blog

33 posts