Control Behaviour
Registers the sap.tnt icon collection with IconPool so a sap-icon://SAP-icons-TNT/... URI resolves - without it the icon renders no glyph and logs nothing.
Z2UI5_CL_SMP_APP_518
Learn
Control Behaviour
UI5 1.71
The facts
- Repository
- abap2UI5/samples
- Class
Z2UI5_CL_SMP_APP_518- Source file
z2ui5_cl_smp_app_518.clas.abap↗- Category
- Control Behaviour
- Learning path
- Reach outside the view
- Minimum UI5
- 1.71 — the floor abap2UI5 holds its samples to
- In the playground
- runs in the browser, with no system and nothing installed
- Documentation
- abap2ui5.github.io/docs/cookbook/event_navigation/frontend ↗
Keywords: icon, font, registerfont, iconpool, tnt, collection, glyph, missing, control_global
Controls it builds
Read out of the builder chain by the abap2UI5 linter, not from the category this sample is filed under — which is what makes “which samples build one of these” a question the catalogue can answer at all.
Libraries
Run it here
The sample running, in this page — the app on its own, with no editor over it.
Switch to Playground with this code
Nothing is installed and nothing is sent anywhere: the ABAP is compiled to JavaScript in this browser and runs against abap2UI5 itself.
The ABAP
z2ui5_cl_smp_app_518.clas.abap — 102 lines
Click a number to link to a line — shift-click for a range.
Read it on GitHub ↗
" @keywords icon font registerfont iconpool tnt collection glyph missing control_global
" @summary Registers the sap.tnt icon collection with IconPool so a sap-icon://SAP-icons-TNT/... URI resolves - without it the icon renders no glyph and logs nothing.
" @docs https://abap2ui5.github.io/docs/cookbook/event_navigation/frontend
CLASS z2ui5_cl_smp_app_518 DEFINITION PUBLIC.
PUBLIC SECTION.
INTERFACES z2ui5_if_app.
PROTECTED SECTION.
DATA client TYPE REF TO z2ui5_if_client.
METHODS view_display.
METHODS font_register.
PRIVATE SECTION.
ENDCLASS.
CLASS z2ui5_cl_smp_app_518 IMPLEMENTATION.
METHOD z2ui5_if_app~main.
me->client = client.
IF client->check_on_init( ).
font_register( ).
view_display( ).
ELSEIF client->check_on_navigated( ).
view_display( ).
ENDIF.
ENDMETHOD.
METHOD font_register.
" A normal UI5 app does this in its Component's init. An abap2UI5 app has
" no Component of its own, and IconPool is a module SINGLETON rather than
" a control, so no other wire reaches it. t_arg is positional: the font
" family and the font URI - a module path in every real use, resolved
" through sap.ui.require.toUrl, so the registration survives a different
" mount point.
"
" Issue it from the init branch: the collection is registered once per
" session, so a repeat call costs nothing but says the wrong thing.
client->follow_up_action( val = z2ui5_if_client=>cs_event-control_global
t_arg = VALUE #( ( `ICON_POOL` )
( `registerFont` )
( `SAP-icons-TNT` )
( `sap/tnt/themes/base/fonts/` ) ) ).
ENDMETHOD.
METHOD view_display.
DATA(view) = z2ui5_cl_ui5_view_builder=>factory(
)->ele( n = `View` ns = `mvc`
)->a( n = `displayBlock` v = `true`
)->a( n = `height` v = `100%`
)->a( n = `xmlns` v = `sap.m`
)->a( n = `xmlns:mvc` v = `sap.ui.core.mvc`
)->a( n = `xmlns:core` v = `sap.ui.core` ).
DATA(page) = view->ele( `Shell`
)->ele( `Page`
)->a( n = `title` v = `abap2UI5 - Control Behaviour - Register an Icon Font`
)->a( n = `showNavButton` b = client->check_app_prev_stack( )
)->a( n = `navButtonPress` v = client->_event_nav_app_leave( ) ).
page->tag( `MessageStrip`
)->a( n = `text` v = `Only the default SAP-icons font is registered out of the box. A URI naming another ` &&
`collection renders NO GLYPH and logs nothing at all - an empty space where an icon should be is the ` &&
`whole symptom, which is what makes this one worth knowing.`
)->a( n = `type` v = `Information`
)->a( n = `showIcon` b = abap_true
)->a( n = `class` v = `sapUiSmallMargin` ).
page->ele( `VBox`
)->a( n = `class` v = `sapUiSmallMargin`
)->tag( `Title`
)->a( n = `text` v = `From the default collection`
)->a( n = `level` v = `H3`
)->tag( n = `Icon` ns = `core`
)->a( n = `src` v = `sap-icon://sap-ui5`
)->a( n = `size` v = `2.5rem`
)->a( n = `class` v = `sapUiSmallMarginBottom`
)->tag( `Title`
)->a( n = `text` v = `From SAP-icons-TNT, registered above`
)->a( n = `level` v = `H3`
)->tag( n = `Icon` ns = `core`
)->a( n = `src` v = `sap-icon://SAP-icons-TNT/application-service`
)->a( n = `size` v = `2.5rem` ).
client->view_display( view->stringify( ) ).
ENDMETHOD.
ENDCLASS.
More in Control Behaviour
- Control Behaviour — Aggregation Item by Index (A)
- Control Behaviour — Expand a Panel by ID (setExpanded) (A)
- Control Behaviour — Inline CSS on a Control (css) (A)
- Control Behaviour — MultiInput with Tokens (C)
- Control Behaviour — Open the PDF Viewer by ID (A)
- Control Behaviour — Switch NavContainer Page by ID (A)
- Control Behaviour — The Global Busy Indicator (A)
- Control Behaviour — Wizard with Steps (A)
On this page