Popover
Opens and closes a Popover by ID (toggleBy), so the anchor decides and no roundtrip is needed.
Z2UI5_CL_SMP_APP_465
Learn
Popover
UI5 1.71
The facts
- Repository
- abap2UI5/samples
- Class
Z2UI5_CL_SMP_APP_465- Source file
z2ui5_cl_smp_app_465.clas.abap↗- Category
- Popover
- Learning path
- Talk to the user
- Minimum UI5
- 1.71 — the floor abap2UI5 holds its samples to
- In the playground
- runs in the browser, with no system and nothing installed
- Documentation
- abap2ui5.github.io/docs/cookbook/popup_popover/popover ↗
Keywords: toggleby, open, close, control_by_id, whitelisted
Controls it builds
- sap.m.Button
- sap.m.MessageStrip
- sap.m.Page
- sap.m.Popover
- sap.m.Shell
- sap.m.Text
- sap.m.VBox
- 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_smp_app_465.clas.abap — 99 lines
Click a number to link to a line — shift-click for a range.
Read it on GitHub ↗
" @keywords toggleby open close control_by_id whitelisted
" @summary Opens and closes a Popover by ID (toggleBy), so the anchor decides and no roundtrip is needed.
" @docs https://abap2ui5.github.io/docs/cookbook/popup_popover/popover https://abap2ui5.github.io/docs/cookbook/event_navigation/frontend
CLASS z2ui5_cl_smp_app_465 DEFINITION PUBLIC.
PUBLIC SECTION.
INTERFACES z2ui5_if_app.
PROTECTED SECTION.
DATA client TYPE REF TO z2ui5_if_client.
METHODS view_display.
METHODS on_event.
PRIVATE SECTION.
ENDCLASS.
CLASS z2ui5_cl_smp_app_465 IMPLEMENTATION.
METHOD z2ui5_if_app~main.
me->client = client.
IF client->check_on_navigated( ).
view_display( ).
ELSE.
on_event( ).
ENDIF.
ENDMETHOD.
METHOD on_event.
IF client->get_event( ) = `TOGGLE`.
" toggle the popover open/closed, anchored to the pressed button's DOM
" ref - the whitelisted toggleBy opens it if closed, closes it if open
" (the controller pattern oPopover.openBy(oButton) / oPopover.close()).
" t_arg is positional: id, method, anchor id (the view defaults to
" cs_view-main and can be omitted for a main-view control)
client->follow_up_action( val = z2ui5_if_client=>cs_event-control_by_id
t_arg = VALUE #( ( `demoPopover` )
( `toggleBy` )
( client->get_event_arg( ) ) ) ).
ENDIF.
ENDMETHOD.
METHOD view_display.
DATA(view) = z2ui5_cl_ui5_view_builder=>factory(
)->ele( n = `View` ns = `mvc`
)->a( n = `displayBlock` v = `true`
)->a( n = `height` v = `100%`
)->a( n = `xmlns` v = `sap.m`
)->a( n = `xmlns:mvc` v = `sap.ui.core.mvc`
)->a( n = `xmlns:core` v = `sap.ui.core` ).
DATA(page) = view->ele( `Shell`
)->ele( `Page`
)->a( n = `title` v = `abap2UI5 - Popover - Toggle by ID (toggleBy)`
)->a( n = `showNavButton` b = client->check_app_prev_stack( )
)->a( n = `navButtonPress` v = client->_event_nav_app_leave( ) ).
" the popover kept as a dependent of the page; opened and closed
" imperatively from the backend, anchored to the button that fired
page->ele( `dependents`
)->ele( `Popover`
)->a( n = `id` v = `demoPopover`
)->a( n = `title` v = `Details`
)->a( n = `placement` v = `Bottom`
)->a( n = `contentWidth` v = `18rem`
)->tag( `Text`
)->a( n = `text` v = `Toggled open and closed from the backend - the same button opens ` &&
`it when closed and closes it when open, no view rebuild and no payload.`
)->end( ).
page->tag( `MessageStrip`
)->a( n = `text` v = `The button toggles the popover via the whitelisted toggleBy method ` &&
`(follow_up_action with cs_event-control_by_id), anchored to the button's DOM ref ` &&
`passed as $event.oSource.sId - open-if-closed, close-if-open, client-side after render.`
)->a( n = `type` v = `Information`
)->a( n = `showIcon` b = abap_true
)->a( n = `class` v = `sapUiSmallMargin` ).
page->ele( `VBox`
)->a( n = `class` v = `sapUiSmallMargin`
)->tag( `Button`
)->a( n = `press` v = client->_event( val = `TOGGLE`
t_arg = VALUE #( ( `$event.oSource.sId` ) ) )
)->a( n = `text` v = `Toggle popover`
)->a( n = `icon` v = `sap-icon://email` ).
client->view_display( view->stringify( ) ).
ENDMETHOD.
ENDCLASS.
More in Popover
On this page