Message Strip with enableFormattedText
A sample MessageStrip that shows status messages with additional formatting.
- Class
z2ui5_cl_smpc_app_062- Repository
- abap2UI5/samples-controls
- Ports
sap.m.sample.MessageStripWithEnableFormattedText- UI5 libraries
- sap.m, sap.ui.core, sap.ui.layout
- Lowest UI5 release
- 1.129
- In the browser
- Runs in the playground
- Controls it builds
- sap.m.Link, sap.m.MessageStrip, sap.ui.core.mvc.View, sap.ui.layout.VerticalLayout
The class
" @keywords messagestrip message strip sap.m strips formatted text verticallayout link
" @summary A sample MessageStrip that shows status messages with additional formatting.
" @origin sap.m.sample.MessageStripWithEnableFormattedText - https://sdk.openui5.org/entity/sap.m.MessageStrip/sample/sap.m.sample.MessageStripWithEnableFormattedText (status: reviewed - read against the original, not run)
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 inlineiconsunicode TYPE string.
DATA inlineiconshelper 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( inlineiconsunicode )
)->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( inlineiconshelper ) }', 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:`.
inlineiconsunicode = `System status: <span class='sapMMsgStripInlineIcon'></span> critical error detected ` &&
`<span class='sapMMsgStripInlineIcon'></span> in module ` &&
`<span class='sapMMsgStripInlineIcon'></span> configuration.`.
inlineiconshelper = `<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.