Jorge Rimblas, DRW
Of Course, You Can Do That with APEX!
DRW, Enterprise APEX Development Team Lead
Introduced in
Conditional processing
Case Conditions
Looping Directive
# What
Tags
Badges
Conditional Content
Cards
Any chunk of HTML...
IF checks for value equality
True | False |
---|---|
Y | N |
T | F |
1 | 0 |
any value | empty |
{if AVAILABLE/}
#PRODUCT#
{endif/}
{if !AVAILABLE/}
#PRODUCT# (Out of Stock)
{endif/}
# IF CODE
#PRODUCT#
{if AVAILABLE/}
#QUANTITY# available
{else/}
Out of Stock
{endif/}
select product
, quantity
, case
when quantity > 0 then
1
else
0
end available
from products
# IF MODIFIERS
Source: apex.oracle.com/ut
New on APEX 23.1
# CASE
{case ITEM/}
{when VALUE1/}
...
{when VALUE2/}
...
{otherwise/}
...
{endcase/}
# CASE
{case CART_STATUS/}
{when NOT_IN_CART/}
<button>Add to cart</button>
{when IN_CART/}
<button>Remove from cart</button>
{otherwise/}
<button>View cart</button>
{endcase/}
select p.first_name || ' ' || p.last_name attendee
, '<table class="table-pref-list " > <tbody> <tr><td>'
|| listagg (
apex_escape.html(prefs.track_name) || '</td> ', '</tr> <tr><td> ')
within group (order by prefs.track_name)
|| '</td></tr> </tbody> </table> ' track_preference
# Via SQL
APEX
Core & DB
Emerging Tech
ks_attendee
ks_tracks
ks_track_xref
{loop "|" COLUMN/}
{endloop/}
# LOOP CODE
{loop "|" COLUMN/}
APEX$I : APEX$ITEM
{endloop/}
# LOOP CODE
APEX|Core & DB|Emerging Tech
1 : APEX
2 : Core & DB
3 : Emerging Tech
APEX$ITEM
// Value of the current item on the list
# Special Symbols
APEX$I
// 1 based index of the current item
// on the list
Track Allocation
------------- ----------
APEX 50
Core & DB 40
Emerging Tech 10
# Alloc Split
APEX|Core & DB|Emerging Tech
# Alloc Split
{loop "|" COLUMN/}
APEX$ITEM
{endloop/}
APEX~50|Core & DB~40|Emerging Tech~10
# Alloc Split
Track Allocation
------------- ----------
APEX 50
Core & DB 40
Emerging Tech 10
# Alloc Split
{loop "|" COLUMN/}
{loop "~" APEX$ITEM/}
APEX$ITEM <br>
{endloop/}
{endloop/}
APEX
50
Core & DB
40
Emerging Tech
10
# Alloc Split
{loop "|" TRACK_PREFERENCE/}
{loop "~" APEX$ITEM/}
{case APEX$I/}
{when 1/}
Track: &APEX$ITEM.
{otherwise/}
Alloc: &APEX$ITEM.<br>
{endcase/}
{endloop/}
{endloop/}
Track: APEX Alloc: 50
Track: Core & DB Alloc: 40
Track: Emerging Tech Alloc: 10
# ALLOC LOOP
T|APEX|P|50|$|
T|APEX|P|70|$|
T|DB|P|30|$|
<div class="row">
{loop "|" TRACK_PREFERENCE/}
{case APEX$ITEM/}
{when T/}<div class="col col-8">
{when P/}<div class="col col-4 u-tR">
{when $/}</div><div class="row">
{otherwise/}&APEX$ITEM.</div>
{endcase/}
{endloop/}
# ALLOC LOOP
T|APEX|P|50|$|
<div class="row">
{loop "|" TRACK_PREFERENCE/}
{case APEX$ITEM/}
{when T/}<div class="col col-8">
{when P/}<div class="col col-4 u-tR">
{when $/}</div><div class="row">
{otherwise/}&APEX$ITEM.</div>
{endcase/}
{endloop/}
# ALLOC LOOP
T|APEX|P|50|$|
<div class="row">
<div class="col col-8">APEX<div>
<div class="col col-4 u-tR">50</div>
</div>
{with/}
LABEL_DISPLAY:=#BADGE_LABEL_DISPLAY#
LABEL:=#BADGE_LABEL#
VALUE:=#BADGE_VALUE#
ICON:=#BADGE_ICON#
STATE:=#BADGE_STATE#
{apply THEME$BADGE/}
# BADGE CODE
{with/}
LABEL_DISPLAY:=Y
LABEL:=Unread Messages
VALUE:=7
ICON:=fa-circle
STATE:=danger
{apply THEME$BADGE/}
# BADGE CODE
{apply THEME$BADGE/}
LABEL_DISPLAY:=#BADGE_LABEL_DISPLAY#
LABEL:=#BADGE_LABEL#
VALUE:=#BADGE_VALUE#
ICON:=#BADGE_ICON#
STATE:=#BADGE_STATE#
{with/}
# BADGE CODE
function THEME$BADGE (
LABEL_DISPLAY => :BADGE_LABEL_DISPLAY
LABEL => :BADGE_LABEL
VALUE => :BADGE_VALUE
ICON => :BADGE_ICON
STATE => :BADGE_STATE
)
return pretty_template
# BADGE CODE
Jorge Rimblas, DRW