Message View with Grouping
A sample with Message View and inside a Dialog and grouping of items
Z2UI5_CL_SMPC_APP_294
Controls
sap.m
UI5 1.71
The facts
- Repository
- abap2UI5/samples-controls
- Class
Z2UI5_CL_SMPC_APP_294- Source file
z2ui5_cl_smpc_app_294.clas.abap↗- Library
- sap.m
- UI5 entity
sap.m.MessageView- Demo kit sample
sap.m.sample.MessageViewWithGrouping- 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, messageviewwithgrouping, overflowtoolbar, button, toolbarspacer, dialog, bar, text, 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.OverflowToolbar
- sap.m.Page
- sap.m.Text
- sap.m.ToolbarSpacer
- 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_294.clas.abap — 290 lines
Click a number to link to a line — shift-click for a range.
Read it on GitHub ↗
" @keywords messageview message sap.m messageviewwithgrouping overflowtoolbar button toolbarspacer dialog bar text messageitem link
" @summary A sample with Message View and inside a Dialog and grouping of items
CLASS z2ui5_cl_smpc_app_294 DEFINITION PUBLIC.
PUBLIC SECTION.
INTERFACES z2ui5_if_app.
TYPES:
BEGIN OF ty_s_message,
type TYPE string,
title TYPE string,
description TYPE string,
subtitle TYPE string,
counter TYPE i,
group TYPE string,
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.
" the three formatters, computed once in the backend (see model_init)
DATA button_icon TYPE string.
DATA button_type TYPE string.
DATA button_text 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_294 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`
)->end(
)->ele( `footer`
)->ele( `OverflowToolbar`
)->tag( `Button`
)->a( n = `id` v = `messageViewBtn`
)->a( n = `icon` v = client->_bind( button_icon )
)->a( n = `type` v = client->_bind( button_type )
)->a( n = `text` v = client->_bind( button_text )
)->a( n = `press` v = client->_event( `MESSAGE_VIEW` )
)->tag( `ToolbarSpacer` ).
client->view_display( view->stringify( ) ).
ENDMETHOD.
METHOD on_event.
CASE client->get_event( ).
WHEN `MESSAGE_VIEW`.
" handleMessageViewPress navigates the MessageView back and opens the
" dialog; the popup is rebuilt here, so it always opens on the list page
back_visible = abap_false.
popup_display( ).
WHEN `ITEM_SELECT`.
back_visible = abap_true.
WHEN `NAV_BACK`.
back_visible = abap_false.
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 = `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( `Text`
)->a( n = `text` v = `Publish order`
)->end(
)->end(
)->end(
)->ele( `content`
)->ele( `MessageView`
)->a( n = `id` v = `messageView`
)->a( n = `showDetailsPageHeader` v = `false`
)->a( n = `groupItems` v = `true`
)->a( n = `items` v = client->_bind( t_messages )
)->a( n = `itemSelect` v = client->_event( `ITEM_SELECT` )
)->ele( `items`
)->ele( `MessageItem`
)->a( n = `type` v = `{TYPE}`
)->a( n = `title` v = `{TITLE}`
)->a( n = `description` v = `{DESCRIPTION}`
)->a( n = `subtitle` v = `{SUBTITLE}`
)->a( n = `counter` v = `{COUNTER}`
)->a( n = `groupName` v = `{GROUP}`
)->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( `endButton`
)->tag( `Button`
)->a( n = `text` v = `Close`
)->a( n = `press` v = client->_event( `CLOSE` ) ).
client->popup_display( popup->stringify( ) ).
ENDMETHOD.
METHOD model_init.
DATA(lv_desc) = `First Error message description. ` && |\n| &&
`Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod` &&
`tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,` &&
`quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo` &&
`consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse` &&
`cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non` &&
`proident, sunt in culpa qui officia deserunt mollit anim id est laborum.`.
" the controller's aMockMessages
t_messages = VALUE #(
( type = `Error`
title = `Account 801 requires an assignment`
subtitle = `Role is invalid`
group = `Purchase Order 450001`
description = lv_desc )
( type = `Warning`
title = `Account 821 requires a check`
subtitle = `Undefined task`
group = `Purchase Order 450001`
description = lv_desc )
( type = `Warning`
title = `Enter a text with maximum 6 characters length`
group = `Purchase Order 450002`
description = lv_desc )
( type = `Warning`
title = `Enter a text with maximum 8 characters length`
group = `Purchase Order 450002`
description = lv_desc )
( type = `Error`
title = `Account 802 requires an assignment`
subtitle = `Role is invalid`
group = `Purchase Order 450002`
description = lv_desc )
( type = `Information`
title = `Account 804 requires an assignment`
subtitle = `Information type subtitle`
group = `Purchase Order 450002`
description = lv_desc )
( type = `Error`
title = `Technical message without object relation`
group = `General`
description = lv_desc )
( type = `Warning`
title = `Global System will be down on Sunday`
group = `General`
description = lv_desc )
( type = `Error`
title = `Global System will be down on Sunday`
group = `General`
description = lv_desc )
( type = `Error`
title = `An Error`
subtitle = `Ungrouped message`
description = lv_desc )
( type = `Warning`
title = `A Warning`
subtitle = `Ungrouped message`
description = lv_desc ) ).
" buttonIconFormatter / buttonTypeFormatter / highestSeverityMessages walk
" the whole message list and pick the highest severity (Error > Warning >
" Success > Information) plus how many messages carry it. That is a
" computation over the data, so it happens here and the Button binds the
" finished values (thin-frontend rule, apps 009/010/022/092)
DATA(lv_top) = `Information`.
LOOP AT t_messages INTO DATA(ls_message).
CASE ls_message-type.
WHEN `Error`.
lv_top = `Error`.
WHEN `Warning`.
IF lv_top <> `Error`.
lv_top = `Warning`.
ENDIF.
WHEN `Success`.
IF lv_top <> `Error` AND lv_top <> `Warning`.
lv_top = `Success`.
ENDIF.
ENDCASE.
ENDLOOP.
CASE lv_top.
WHEN `Error`.
button_icon = `sap-icon://message-error`.
button_type = `Negative`.
WHEN `Warning`.
button_icon = `sap-icon://message-warning`.
button_type = `Critical`.
WHEN `Success`.
button_icon = `sap-icon://message-success`.
button_type = `Success`.
WHEN OTHERS.
button_icon = `sap-icon://message-information`.
button_type = `Neutral`.
ENDCASE.
button_text = |{ REDUCE i( INIT x = 0 FOR ls_row IN t_messages NEXT x = COND #( WHEN ls_row-type = lv_top THEN x + 1 ELSE x ) ) }|.
ENDMETHOD.
ENDCLASS.
More in sap.m
- 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
- Notification List Group with data bindings — A control suitable for grouping notifications. The sample uses JSON data bindings.
- Panel - Background Design — Panels support different background designs for better visual distinction inside containe…
- View Settings Dialog - Custom Filters — You can have custom filters in your View Settings Dialog, as shown in this example here.
- View Settings Dialog - Custom Search — You can filter the items in the filter details page using different string filter operato…
- View Settings Dialog - Custom Tabs — You can have custom tabs with your own defined content in the View Settings Dialog, as sh…
- Table - View Settings & Menus — The View Settings Dialog is standard UI pattern for specifying sorting, grouping and filt…
- Input - Description — This sample illustrates the usage of the description with input fields, e.g. description…
- Input - Password — To make sure the password is not shown as clear text you set the 'type' of an input contr…
On this page