Message View inside Dialog
A sample with Message View placed inside a Dialog.
Z2UI5_CL_SMPC_APP_284
Controls
sap.m
UI5 1.71
The facts
- Repository
- abap2UI5/samples-controls
- Class
Z2UI5_CL_SMPC_APP_284- Source file
z2ui5_cl_smpc_app_284.clas.abap↗- Library
- sap.m
- UI5 entity
sap.m.MessageView- Demo kit sample
sap.m.sample.MessageViewInsideDialog- SAP's own sample
- running at sdk.openui5.org ↗
- Minimum UI5
- 1.71 — the floor abap2UI5 holds its samples to
- In the playground
- runs in the browser, with no system and nothing installed
Keywords: messageview, message, sap.m, messageviewinsidedialog, button, dialog, bar, title, messageitem, link
Controls it builds
- sap.m.Bar
- sap.m.Button
- sap.m.Dialog
- sap.m.Link
- sap.m.MessageItem
- sap.m.MessageView
- sap.m.Page
- sap.m.Title
- sap.ui.core.FragmentDefinition
- sap.ui.core.mvc.View
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_284.clas.abap — 228 lines
Click a number to link to a line — shift-click for a range.
Read it on GitHub ↗
" @keywords messageview message sap.m messageviewinsidedialog button dialog bar title messageitem link
" @summary A sample with Message View placed inside a Dialog.
CLASS z2ui5_cl_smpc_app_284 DEFINITION PUBLIC.
PUBLIC SECTION.
INTERFACES z2ui5_if_app.
TYPES:
BEGIN OF ty_s_message,
type TYPE string,
title TYPE string,
activetitle TYPE abap_bool,
description TYPE string,
subtitle TYPE string,
counter TYPE i,
markupdescription TYPE abap_bool,
END OF ty_s_message.
TYPES ty_t_message TYPE STANDARD TABLE OF ty_s_message WITH EMPTY KEY.
DATA t_messages TYPE ty_t_message.
DATA dialog_title TYPE string.
DATA back_visible TYPE abap_bool.
PROTECTED SECTION.
DATA client TYPE REF TO z2ui5_if_client.
METHODS view_display.
METHODS on_event.
METHODS popup_display.
METHODS model_init.
PRIVATE SECTION.
ENDCLASS.
CLASS z2ui5_cl_smpc_app_284 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( ).
ELSEIF client->check_on_event( ).
on_event( ).
ENDIF.
ENDMETHOD.
METHOD view_display.
DATA(view) = z2ui5_cl_ui5_view_builder=>factory( ).
view->ele( n = `View` ns = `mvc`
)->a( n = `height` v = `100%`
)->a( n = `xmlns:l` v = `sap.ui.layout`
)->a( n = `xmlns:mvc` v = `sap.ui.core.mvc`
)->a( n = `xmlns` v = `sap.m`
)->ele( `Page`
)->a( n = `showHeader` v = `false`
)->ele( `content`
)->tag( `Button`
)->a( n = `text` v = `Delete`
)->a( n = `class` v = `sapUiLargeMarginBegin sapUiLargeMarginTop`
)->a( n = `press` v = client->_event( `DIALOG` ) ).
client->view_display( view->stringify( ) ).
ENDMETHOD.
METHOD on_event.
CASE client->get_event( ).
WHEN `DIALOG`.
" handleDialogPress navigates the MessageView back before opening; the
" popup is rebuilt here, so only the header state has to reset
dialog_title = `Messages`.
back_visible = abap_false.
popup_display( ).
WHEN `ITEM_SELECT`.
" itemSelect reveals the back button and retitles the dialog
back_visible = abap_true.
dialog_title = `Message Details`.
WHEN `NAV_BACK`.
back_visible = abap_false.
dialog_title = `Messages`.
client->follow_up_action( val = client->cs_event-control_by_id
view = client->cs_view-popup
t_arg = VALUE #( ( `messageView` ) ( `navigateBack` ) ) ).
WHEN `CLOSE`.
client->popup_destroy( ).
ENDCASE.
ENDMETHOD.
METHOD popup_display.
DATA(popup) = z2ui5_cl_ui5_view_builder=>factory( ).
popup->ele( n = `FragmentDefinition` ns = `core`
)->a( n = `xmlns:core` v = `sap.ui.core`
)->a( n = `xmlns` v = `sap.m`
)->ele( `Dialog`
)->a( n = `resizable` v = `true`
)->a( n = `state` v = `Error`
)->a( n = `contentHeight` v = `50%`
)->a( n = `contentWidth` v = `50%`
)->a( n = `verticalScrolling` v = `false`
)->ele( `customHeader`
)->ele( `Bar`
)->ele( `contentLeft`
)->tag( `Button`
)->a( n = `icon` v = `sap-icon://nav-back`
)->a( n = `visible` v = client->_bind( back_visible )
)->a( n = `press` v = client->_event( `NAV_BACK` )
)->end(
)->ele( `contentMiddle`
)->tag( `Title`
)->a( n = `text` v = client->_bind( dialog_title )
)->a( n = `level` v = `H1`
)->end(
)->end(
)->end(
)->ele( `content`
)->ele( `MessageView`
)->a( n = `id` v = `messageView`
)->a( n = `showDetailsPageHeader` v = `false`
)->a( n = `items` v = client->_bind( t_messages )
)->a( n = `itemSelect` v = client->_event( `ITEM_SELECT` )
" the original composes this toast on the client, so it stays there
)->a( n = `activeTitlePress` v = client->follow_up_action( val = client->cs_event-control_global
t_arg = VALUE #( ( `MESSAGE_TOAST` ) ( `show` ) ( `Active title pressed` ) ) )
)->ele( `items`
)->ele( `MessageItem`
)->a( n = `type` v = `{TYPE}`
)->a( n = `title` v = `{TITLE}`
)->a( n = `activeTitle` v = `{ACTIVETITLE}`
)->a( n = `description` v = `{DESCRIPTION}`
)->a( n = `subtitle` v = `{SUBTITLE}`
)->a( n = `counter` v = `{COUNTER}`
)->a( n = `markupDescription` v = `{MARKUPDESCRIPTION}`
)->ele( `link`
)->tag( `Link`
)->a( n = `text` v = `Show more information`
)->a( n = `href` v = `http://sap.com`
)->a( n = `target` v = `_blank`
)->end(
)->end(
)->end(
)->end(
)->end(
)->ele( `beginButton`
)->tag( `Button`
)->a( n = `text` v = `Close`
)->a( n = `press` v = client->_event( `CLOSE` ) ).
client->popup_display( popup->stringify( ) ).
ENDMETHOD.
METHOD model_init.
dialog_title = `Messages`.
" the controller's aMockMessages
t_messages = VALUE #(
( type = `Error`
title = `Error message`
description = `First Error message description. ` && |\n| && `Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod`
subtitle = `Example of subtitle`
counter = 1 )
( type = `Warning`
title = `Warning without description`
description = `` )
( type = `Success`
title = `Success message`
description = `First Success message description`
subtitle = `Example of subtitle`
counter = 1 )
( type = `Error`
title = `Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. `
&& `Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris `
description = `Second Error message description`
subtitle = `Example of subtitle`
counter = 2 )
( type = `Information`
title = `Information message`
description = `First Information message description`
subtitle = `Example of long subtitle lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et `
&& `dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris `
counter = 1 )
( type = `Success`
title = `Success message with active title`
description = `Second Success message description`
subtitle = `Example of subtitle`
activetitle = abap_true
counter = 1 ) ).
ENDMETHOD.
ENDCLASS.
More in sap.m
- List - Growing — The Growing feature helps if your content is too big to be loaded/shown at once. It pagin…
- Table - ContextualWidth (Dynamic) — This example shows the container-based pop-in behavior. The container has dynamic width.
- Message Box — MessageBox is an easy way of displaying a message-type dialog to the user. You can displa…
- Image error handling with IllustratedMessage — Handle errors using the sap.m.IllustratedMessage with the error event.
- TextArea - Value Update — Since 1.30 the value property of sap.m.TextArea is not updated on every keystroke, but fi…
- MultiComboBox - showSelectAll functionality — MultiComboBox with enabled Select All feature inside suggestions.
- Popover in Custom Within Area — Within area of sap.ui.core.Popup determines where all popups (including popovers) are pos…
- Breadcrumbs sample with current page link — Breadcrumbs sample with current page set as aggregation, resulting in a link
- Icon Tab Bar - Badges — This sample illustrates the possibility to add badges to the icon tab filters.
- PDF Viewer - Embedded — A PDF viewer embedded in another control.
- Dynamic Message Strip Generator — Generates MessageStrips with random properties.
- MultiInput with Value Help — MultiInput that includes a SelectDialog as a value help dialog
On this page