Semantic Page using Draft Indicator
Integration of Draft Indicator inside Semantic Page
Z2UI5_CL_SMPC_APP_448
Controls
sap.m
UI5 1.71
The facts
- Repository
- abap2UI5/samples-controls
- Class
Z2UI5_CL_SMPC_APP_448- Source file
z2ui5_cl_smpc_app_448.clas.abap↗- Library
- sap.m
- UI5 entity
sap.m.DraftIndicator- Demo kit sample
sap.m.sample.SemanticPageDraftIndicator- 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: draftindicator, draft, indicator, sap.m, semanticpagedraftindicator, fullscreenpage, addaction, flagaction, favoriteaction, messagesindicator, messagepopover, messageitem
Controls it builds
- sap.m.DraftIndicator
- sap.m.Input
- sap.m.Label
- sap.m.MessageItem
- sap.m.MessagePopover
- sap.m.ObjectHeader
- sap.m.semantic.AddAction
- sap.m.semantic.FavoriteAction
- sap.m.semantic.FlagAction
- sap.m.semantic.FullscreenPage
- sap.m.semantic.MessagesIndicator
- sap.ui.core.mvc.View
- sap.ui.layout.form.SimpleForm
- z2ui5.cc.MessageManager
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_448.clas.abap — 182 lines
Click a number to link to a line — shift-click for a range.
Read it on GitHub ↗
" @keywords draftindicator draft indicator sap.m semanticpagedraftindicator fullscreenpage addaction flagaction favoriteaction messagesindicator messagepopover messageitem
" @summary Integration of Draft Indicator inside Semantic Page
CLASS z2ui5_cl_smpc_app_448 DEFINITION PUBLIC.
PUBLIC SECTION.
INTERFACES z2ui5_if_app.
TYPES: BEGIN OF ty_s_message,
type TYPE string,
message TYPE string,
description 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.
DATA type_here TYPE string.
PROTECTED SECTION.
DATA client TYPE REF TO z2ui5_if_client.
METHODS view_display.
METHODS on_event.
METHODS model_init.
PRIVATE SECTION.
ENDCLASS.
CLASS z2ui5_cl_smpc_app_448 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:core` v = `sap.ui.core`
)->a( n = `xmlns:mvc` v = `sap.ui.core.mvc`
)->a( n = `xmlns` v = `sap.m`
)->a( n = `xmlns:semantic` v = `sap.m.semantic`
)->a( n = `xmlns:form` v = `sap.ui.layout.form`
)->a( n = `xmlns:z2ui5` v = `z2ui5.cc`
)->a( n = `displayBlock` v = `true`
)->ele( n = `FullscreenPage` ns = `semantic`
)->a( n = `title` v = `FullScreen Page Title`
)->a( n = `showNavButton` v = `true`
)->a( n = `navButtonPress` v = client->follow_up_action( val = client->cs_event-control_global
t_arg = VALUE #( ( `MESSAGE_TOAST` ) ( `show` ) ( `Pressed navigation button` ) ) )
" onSemanticButtonPress toasts the source's class name with the library
" prefix stripped - the class name travels, the strip happens in ABAP
)->ele( n = `addAction` ns = `semantic`
)->tag( n = `AddAction` ns = `semantic`
)->a( n = `press` v = client->_event( val = `SEMANTIC_PRESS` arg = `$event.oSource.getMetadata().getName()` )
)->end(
)->ele( n = `flagAction` ns = `semantic`
)->tag( n = `FlagAction` ns = `semantic`
)->a( n = `press` v = client->_event( val = `SEMANTIC_PRESS` arg = `$event.oSource.getMetadata().getName()` )
)->end(
)->ele( n = `favoriteAction` ns = `semantic`
)->tag( n = `FavoriteAction` ns = `semantic`
)->a( n = `press` v = client->_event( val = `SEMANTIC_PRESS` arg = `$event.oSource.getMetadata().getName()` )
)->end(
)->ele( n = `messagesIndicator` ns = `semantic`
)->ele( n = `MessagesIndicator` ns = `semantic`
)->a( n = `press` v = client->follow_up_action( val = client->cs_event-control_by_id
t_arg = VALUE #( ( `draftMessagePopover` ) ( `toggleBy` ) ( `$event.oSource.sId` ) ) )
" the controller-built MessagePopover over the message model,
" declared as a dependent of its anchor (app 107 precedent)
)->ele( n = `dependents` ns = `semantic`
)->ele( `MessagePopover`
)->a( n = `id` v = `draftMessagePopover`
)->a( n = `items` v = `{message>/}`
)->tag( `MessageItem`
)->a( n = `description` v = `{message>description}`
)->a( n = `type` v = `{message>type}`
)->a( n = `title` v = `{message>message}`
)->end(
)->end(
)->end(
)->end(
)->ele( n = `draftIndicator` ns = `semantic`
)->tag( `DraftIndicator`
)->a( n = `id` v = `draftIndi`
)->a( n = `state` v = `Saved`
)->end(
)->ele( n = `content` ns = `semantic`
" added container (declared): the z2ui5.cc.MessageManager bridge
" reproducing onInit's MessageManager.addMessages seed
)->tag( n = `MessageManager` ns = `z2ui5`
)->a( n = `items` v = client->_bind( t_messages )
)->tag( `ObjectHeader`
)->a( n = `title` v = `Type something in the field, the Draft Indicator will be displayed in the footer`
)->a( n = `intro` v = `this is just a simulation of how the DraftIndicator will work`
)->a( n = `responsive` v = `true`
)->ele( n = `SimpleForm` ns = `form`
)->a( n = `editable` v = `true`
)->a( n = `layout` v = `ResponsiveGridLayout`
)->tag( `Label`
)->a( n = `text` v = `Type here`
" handleLiveChange runs showDraftSaving( ), showDraftSaved( ) and
" clearDraftState( ) one after the other. Those three do NOT
" collapse into the last one - DraftIndicator is queue-driven
" with a minDisplayTime of 1500 ms: showDraftSaving pushes
" [Saving, Clear] and _processQueue paints "Saving..." at once
" and arms a 1500 ms timer, after which the two later calls -
" which only queued, because _processQueue returns early while
" iDelayedCallId is set - are drained, painting "Draft saved"
" for another 1500 ms. So the original visibly shows
" Saving... -> Draft saved on every keystroke, which is what
" the sample's own header text advertises. Making only the
" clearDraftState call showed nothing at all (corrected
" 2026-08-24); all three now travel, in order.
" One call carries it: showDraftSaving alone queues
" [Saving, Clear], so the indicator shows "Saving..." for its
" minDisplayTime and then clears itself - roundtrip-free, on
" every keystroke, exactly where the original calls it.
" What is NOT reproduced is the intermediate "Draft saved"
" label: an event attribute carries ONE action, and routing
" the three calls through a round-trip instead would put a
" server hop on every keystroke - the lossy pattern AGENTS
" section 10 warns about and the advisory ratchet budgets.
" Showing Saving... and clearing is the closer half.
)->tag( `Input`
)->a( n = `id` v = `TypeHere`
)->a( n = `value` v = client->_bind( type_here )
)->a( n = `liveChange` v = client->follow_up_action( val = client->cs_event-control_by_id
t_arg = VALUE #( ( `draftIndi` ) ( `showDraftSaving` ) ) ) ).
client->view_display( view->stringify( ) ).
ENDMETHOD.
METHOD on_event.
IF client->get_event( ) = `SEMANTIC_PRESS`.
" the original strips the LIBRARY name, so sap.m.semantic.AddAction
" reaches the toast as semantic.AddAction
DATA(action) = replace( val = client->get_event_arg( ) sub = `sap.m.` with = `` ).
client->message_toast_display( |Pressed: { action }| ).
ENDIF.
ENDMETHOD.
METHOD model_init.
" onInit registers a ControlMessageProcessor and adds one error message
t_messages = VALUE #( ( type = `Error` message = `Something wrong happened` ) ).
ENDMETHOD.
ENDCLASS.
More in sap.m
- PDF Viewer - Two PDF Documents — Two PDF viewer frames displayed side by side. The second frame has the property isTrusted…
- Text - Render Whitespace — The Text control has a property allowing browsers to render whitespace and tabs.
- Notification List Group with max number of notifications reached — Notification List Group with max number of notifications reached. The group will render t…
- Text - Hyphenation — The Text control has a property allowing hyphenation.
- Link - Subtle — Subtle links should be used to indicate less important links in tables with a large numbe…
- Message Box Details — MessageBox with the option to display detailed information.
- Tab Container - with icons and additional text — This example shows how you can add additional text and an Icon to the tabs in TabContaine…
- Custom Message Strip Design — Demonstrates MessageStrips with different colorSet and colorScheme properties.
- Object Header Responsive I — This is a responsive Object Header with a Title, 2 Statuses/Attributes rendered next to t…
- Table Select Dialog Growing — Table Select Dialog can be created with property growing set to true or false.
- ComboBox - Clear Icon — The combo box control can show 'clear' icon, which when pressed will remove the user's in…
- Input - Assisted Two Values — This example shows how to easily implement an assisted input with two-value suggestions.
On this page