Message Strip with enableFormattedText
A sample MessageStrip that shows status messages with additional formatting.
Z2UI5_CL_SMPC_APP_062
Controls
sap.m
UI5 1.129
The facts
- Repository
- abap2UI5/samples-controls
- Class
Z2UI5_CL_SMPC_APP_062- Source file
z2ui5_cl_smpc_app_062.clas.abap↗- Library
- sap.m
- UI5 entity
sap.m.MessageStrip- Demo kit sample
sap.m.sample.MessageStripWithEnableFormattedText- SAP's own sample
- running at sdk.openui5.org ↗
- Minimum UI5
- 1.129
- In the playground
- runs in the browser, with no system and nothing installed
Keywords: messagestrip, message, strip, sap.m, strips, formatted, text, verticallayout, link
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_smpc_app_062.clas.abap — 149 lines
Click a number to link to a line — shift-click for a range.
Read it on GitHub ↗
" @keywords messagestrip message strip sap.m strips formatted text verticallayout link
" @summary A sample MessageStrip that shows status messages with additional formatting.
CLASS z2ui5_cl_smpc_app_062 DEFINITION PUBLIC.
PUBLIC SECTION.
INTERFACES z2ui5_if_app.
DATA default_text TYPE string.
DATA error_text TYPE string.
DATA warning_text TYPE string.
DATA success_text TYPE string.
DATA inline_icons_unicode TYPE string.
DATA inline_icons_helper TYPE string.
PROTECTED SECTION.
DATA client TYPE REF TO z2ui5_if_client.
METHODS view_display.
METHODS model_init.
PRIVATE SECTION.
ENDCLASS.
CLASS z2ui5_cl_smpc_app_062 IMPLEMENTATION.
METHOD z2ui5_if_app~main.
me->client = client.
IF client->check_on_init( ).
model_init( ).
view_display( ).
ELSEIF client->check_on_navigated( ).
view_display( ).
ENDIF.
ENDMETHOD.
METHOD view_display.
DATA(view) = z2ui5_cl_ui5_view_builder=>factory( ).
view->ele( n = `View` ns = `mvc`
)->a( n = `xmlns:l` v = `sap.ui.layout`
)->a( n = `xmlns:core` v = `sap.ui.core`
)->a( n = `xmlns:mvc` v = `sap.ui.core.mvc`
)->a( n = `xmlns` v = `sap.m`
" POST-1.71: core:require (since UI5 1.74) wires the curated formatter module; not in the sample view
)->a( n = `core:require` v = `{Formatter: 'z2ui5/model/formatter'}`
)->ele( n = `VerticalLayout` ns = `l`
)->a( n = `class` v = `sapUiContentPadding`
)->a( n = `width` v = `100%`
)->ele( n = `content` ns = `l`
)->tag( `MessageStrip`
)->a( n = `text` v = client->_bind( default_text )
)->a( n = `enableFormattedText` v = `true`
)->a( n = `showIcon` v = `true`
)->a( n = `showCloseButton` v = `true`
)->a( n = `class` v = `sapUiMediumMarginBottom`
)->tag( `MessageStrip`
)->a( n = `text` v = client->_bind( error_text )
)->a( n = `type` v = `Error`
)->a( n = `enableFormattedText` v = `true`
)->a( n = `showIcon` v = `true`
)->a( n = `showCloseButton` v = `true`
)->a( n = `class` v = `sapUiMediumMarginBottom`
)->tag( `MessageStrip`
)->a( n = `text` v = client->_bind( warning_text )
)->a( n = `type` v = `Warning`
)->a( n = `enableFormattedText` v = `true`
)->a( n = `showIcon` v = `true`
)->a( n = `showCloseButton` v = `true`
)->a( n = `class` v = `sapUiMediumMarginBottom`
)->tag( `MessageStrip`
)->a( n = `text` v = client->_bind( success_text )
)->a( n = `type` v = `Success`
)->a( n = `enableFormattedText` v = `true`
)->a( n = `showIcon` v = `true`
)->a( n = `showCloseButton` v = `true`
)->a( n = `class` v = `sapUiMediumMarginBottom`
)->ele( `MessageStrip`
)->a( n = `text` v = `Information with multiple links %%0 %%1 %%2`
)->a( n = `enableFormattedText` v = `true`
)->a( n = `showIcon` v = `true`
)->a( n = `showCloseButton` v = `true`
)->a( n = `class` v = `sapUiMediumMarginBottom`
" POST-1.71: the controls aggregation (since UI5 1.129) kept 1:1 for the multi-link formatted text
)->ele( `controls`
)->tag( `Link`
)->a( n = `href` v = `http://www.sap.com`
)->a( n = `text` v = `Link 1`
)->tag( `Link`
)->a( n = `href` v = `http://www.sap.com`
)->a( n = `text` v = `Link 2`
)->tag( `Link`
)->a( n = `href` v = `http://www.sap.com`
)->a( n = `text` v = `Link 3`
)->end(
)->end(
)->tag( `MessageStrip`
)->a( n = `text` v = client->_bind( inline_icons_unicode )
)->a( n = `type` v = `Warning`
)->a( n = `enableFormattedText` v = `true`
)->a( n = `showIcon` v = `true`
)->a( n = `showCloseButton` v = `true`
)->a( n = `class` v = `sapUiMediumMarginBottom`
)->tag( `MessageStrip`
" the controller-built inline-icon string is stored with icon placeholders and expanded by Formatter.expandInlineIcons (see sidecar)
)->a( n = `text` v = |\{ path: '{ client->_bind_path( inline_icons_helper ) }', formatter: 'Formatter.expandInlineIcons' \}|
)->a( n = `type` v = `Success`
)->a( n = `enableFormattedText` v = `true`
)->a( n = `showIcon` v = `true`
)->a( n = `showCloseButton` v = `true`
)->a( n = `class` v = `sapUiMediumMarginBottom` ).
client->view_display( view->stringify( ) ).
ENDMETHOD.
METHOD model_init.
" the sample's static JSONModel strings, verbatim; field names differ from the JSON keys (default becomes default_text etc., see sidecar)
default_text = `Default <em>(Information)</em> with default icon and <strong>close button</strong>:`.
error_text = `<strong>Error</strong> with link to <a target="_blank" href="http://www.sap.com">SAP Homepage</a> <em>(For more info)</em>`.
warning_text = `<strong>Warning</strong> with default icon and close button:`.
success_text = `<strong>Success</strong> with default icon and close button:`.
inline_icons_unicode = `System status: <span class='sapMMsgStripInlineIcon'></span> critical error detected ` &&
`<span class='sapMMsgStripInlineIcon'></span> in module ` &&
`<span class='sapMMsgStripInlineIcon'></span> configuration.`.
inline_icons_helper = `<strong>Deployment successful!</strong> %%icon:sap-icon://message-success%% All services ` &&
`%%icon:sap-icon://sys-enter-2%% are running. <em>Check status</em> ` &&
`%%icon:sap-icon://stethoscope%%`.
ENDMETHOD.
ENDCLASS.
More in sap.m
- ImageContent — Shows ImageContent that can include an icon, a profile image, or a logo with a tooltip.
- Input List Item — Use the Input List Item on phones to build form like user interfaces.
- Label Properties — This sample shows the different behaviors of a label.
- LightBox — Displays several image thumbnails. Clicking on each of them will open a LightBox.
- Menu — This control is used to show a menu in both desktop and mobile.
- Menu Button — This control is used to open a menu in both desktop and mobile.
- News Content — This control is used to display the news content text and subheader in a tile.
- Numeric Content with Icon — Shows NumericContent including an icon.
- Message Popover - Message Handling — The message handling concept sample shows how you can connect an error inside the page (s…
- MessagePopover — MessagePopover is a control that displays a summarized list of different types of message…
- Message Popover - Async Message Handling — The message handling concept sample shows how you can use callback functions for resolvin…
- Slider — With the Slider a user can choose a value from a numerical range.
On this page