It sounds like an easy task, but it took me a while to get a badge list query working. Just to be clear, I’m talking about the query you have to define when creating a dynamic list in Shared Components. You can then create a list region on a page based on that list. Here is a working example query:

select null as lvl,
       'My Amazing Label' as label,
       'javascript:void(0);' as target,
       null as attribute1,
       null as attribute2,
       null as attribute3,
       null as attribute4,
       42 as attribute5,
       'custom-list-class' as attribute6,
       'custom-a-tag-attr' as attribute7
from dual

It turns out that a lot of things can go wrong with this kind of query.

  • The first column in the query must be the level, which is completely useless for a badge list query. However, you are required to specify this column. Neglecting to do so will result in the following error message when running the page:
    ORA-06502: PL/SQL: numeric or value error: character to number conversion error
    Simply specify NULL or 1 as the level value.
    Don’t use the word level as an alias by the way. Level is a reserved keyword in SQL.
  • The second column lets you define the badge label. This column is required as well. Use NULL if you don’t want to display a label.
  • The next required column is the target value, which allows you to provide a link for the badge.
    • Use javascript:void(0); to make the badge not linkable.
    • Specifying NULL will generate a link to the current page.
  • Attribute 1 to 4 are not being used, but they are required.
  • Attribute 5 is the value that shows in the badge. Needless to say that this column is required.
  • Attribute 6 is optional (finally). You can use it to add one or more custom classes to the <li> tag of the badge.
  • Attribute 7 is also optional and can be used to add custom HTML attributes to the <a> tag of the target column.

A small tip: use the UNION ALL set operator to add more badge items.

select null as lvl,
       'My Amazing Label' as label,
       'javascript:void(0);' as target,
       null as attribute1,
       null as attribute2,
       null as attribute3,
       null as attribute4,
       42 as attribute5,
       'custom-list-class' as attribute6,
       'custom-a-tag-attr' as attribute7
from dual
union all
select null as lvl,
       'Another Label' as label,
       null as target,
       null as attribute1,
       null as attribute2,
       null as attribute3,
       null as attribute4,
       101 as attribute5,
       null as attribute6,
       null as attribute7
from dual

To make things even more complicated, the Badge List template in Universal Theme uses the #A01##A02# and #A03# substitution strings.

<li class="t-BadgeList-item #A02#">
  <span class="t-BadgeList-label">#TEXT#</span>
  <span class="t-BadgeList-value"><a href="#LINK#" #A03#>#A01#</a></span>
</li>

However, the badge list query works with attributes 5, 6 and 7. Pretty weird, right?