Responsive Popover
The Responsive Popover is an abstraction of Popover and Dialog. On the phone a Dialog will be shown. On tablet and desktop a Popover is shown.
Z2UI5_CL_SMPC_APP_243
Controls
sap.m
UI5 1.129
The facts
- Repository
- abap2UI5/samples-controls
- Class
Z2UI5_CL_SMPC_APP_243- Source file
z2ui5_cl_smpc_app_243.clas.abap↗- Library
- sap.m
- UI5 entity
sap.m.ResponsivePopover- Demo kit sample
sap.m.sample.ResponsivePopover- SAP's own sample
- running at sdk.openui5.org ↗
- Minimum UI5
- 1.129
- In the playground
- runs in the browser, with no system and nothing installed
Keywords: responsivepopover, responsive, popover, sap.m, verticallayout, button, image, overflowtoolbar, toolbarspacer
Controls it builds
- sap.m.Button
- sap.m.Image
- sap.m.OverflowToolbar
- sap.m.ResponsivePopover
- sap.m.ToolbarSpacer
- sap.ui.core.FragmentDefinition
- sap.ui.core.mvc.View
- sap.ui.layout.VerticalLayout
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_243.clas.abap — 178 lines
Click a number to link to a line — shift-click for a range.
Read it on GitHub ↗
" @keywords responsivepopover responsive popover sap.m verticallayout button image overflowtoolbar toolbarspacer
" @summary The Responsive Popover is an abstraction of Popover and Dialog. On the phone a Dialog will be shown. On tablet and desktop a Popover is shown.
CLASS z2ui5_cl_smpc_app_243 DEFINITION PUBLIC.
PUBLIC SECTION.
INTERFACES z2ui5_if_app.
" both popovers bindElement("/ProductCollection/0") - a single record; its
" fields are seeded at the default-model root so the fragments' relative
" {NAME}/{PRODUCTPICURL} bindings resolve against the model root
DATA name TYPE string.
DATA productpicurl 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_243 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 = `xmlns:l` v = `sap.ui.layout`
)->a( n = `xmlns:mvc` v = `sap.ui.core.mvc`
)->a( n = `xmlns` v = `sap.m`
)->ele( n = `VerticalLayout` ns = `l`
)->a( n = `class` v = `sapUiContentPadding`
)->a( n = `width` v = `100%`
)->ele( n = `content` ns = `l`
)->tag( `Button`
)->a( n = `text` v = `Show Dialog (phone) or Popover (Other)`
" handleResponsivePopoverPress: Fragment.load(Popover) -> openBy(button)
)->a( n = `press` v = client->_event( val = `SHOW_POPOVER` arg = `$event.oSource.sId` )
)->a( n = `ariaHasPopup` v = `Dialog`
)->tag( `Button`
)->a( n = `text` v = `Popover with Custom Footer`
" handleResponsivePopoverFooterPress: Fragment.load(PopoverFooter) -> openBy(button)
)->a( n = `press` v = client->_event( val = `SHOW_POPOVER_FOOTER` arg = `$event.oSource.sId` )
)->a( n = `ariaHasPopup` v = `Dialog`
)->end(
)->end( ).
client->view_display( view->stringify( ) ).
ENDMETHOD.
METHOD on_event.
CASE client->get_event( ).
WHEN `SHOW_POPOVER`.
" Popover.fragment.xml: a ResponsivePopover with begin/end action buttons,
" built server-side and shown anchored to the pressed button
" ($event.oSource.sId); bindElement("/ProductCollection/0") is folded to
" the root-seeded fields (relative {NAME}/{PRODUCTPICURL} resolve there)
DATA(popover) = z2ui5_cl_ui5_view_builder=>factory( ).
popover->ele( n = `FragmentDefinition` ns = `core`
)->a( n = `xmlns` v = `sap.m`
)->a( n = `xmlns:core` v = `sap.ui.core`
)->ele( `ResponsivePopover`
)->a( n = `id` v = `myPopover`
)->a( n = `title` v = client->_bind( name )
)->a( n = `class` v = `sapUiContentPadding`
)->a( n = `placement` v = `Bottom`
)->ele( `beginButton`
)->tag( `Button`
)->a( n = `text` v = `Action-A`
)->a( n = `press` v = client->_event( `CLOSE` )
)->end(
)->ele( `endButton`
)->tag( `Button`
)->a( n = `text` v = `Action-B`
)->a( n = `press` v = client->_event( `CLOSE` )
)->end(
)->ele( `content`
)->tag( `Image`
)->a( n = `src` v = client->_bind( productpicurl )
)->a( n = `width` v = `15em`
)->end(
)->end( ).
client->popover_display( xml = popover->stringify( )
by_id = client->get_event_arg( ) ).
WHEN `SHOW_POPOVER_FOOTER`.
" PopoverFooter.fragment.xml: a ResponsivePopover with a custom footer
" OverflowToolbar (OK / Cancel), same anchoring + root-seeded record
DATA(footer) = z2ui5_cl_ui5_view_builder=>factory( ).
footer->ele( n = `FragmentDefinition` ns = `core`
)->a( n = `xmlns` v = `sap.m`
)->a( n = `xmlns:core` v = `sap.ui.core`
)->ele( `ResponsivePopover`
)->a( n = `id` v = `myFooterPopover`
)->a( n = `title` v = client->_bind( name )
)->a( n = `class` v = `sapUiContentPadding`
)->a( n = `placement` v = `Bottom`
)->a( n = `contentWidth` v = `320px`
)->a( n = `horizontalScrolling` v = `false`
)->ele( `content`
)->tag( `Image`
)->a( n = `src` v = client->_bind( productpicurl )
)->a( n = `width` v = `15em`
)->end(
)->ele( `footer`
)->ele( `OverflowToolbar`
)->ele( `content`
)->tag( `ToolbarSpacer`
)->tag( `Button`
)->a( n = `text` v = `OK`
)->tag( `Button`
)->a( n = `text` v = `Cancel`
)->a( n = `press` v = client->_event( `CLOSE` )
)->end(
)->end(
)->end(
)->end( ).
client->popover_display( xml = footer->stringify( )
by_id = client->get_event_arg( ) ).
WHEN `CLOSE`.
" handleCloseButton / handleCloseFooterButton: byId(...).close() - one
" popover slot is open at a time, so a single popover_close covers both
client->follow_up_action( client->cs_event-popover_close ).
ENDCASE.
ENDMETHOD.
METHOD model_init.
" /ProductCollection/0 of ui5/mock/products.json - the single record both
" popovers bindElement to; the picture URL points at the OpenUI5 host
name = `Notebook Basic 15`.
productpicurl = `https://sdk.openui5.org/test-resources/sap/ui/documentation/sdk/images/HT-1000.jpg`.
ENDMETHOD.
ENDCLASS.
More in sap.m
- Popover — The Popover controls allows to show contextual information without leaving the current pa…
- InitialPage Pattern — The initial page floorplan allows the user to navigate to a single object to view or edit…
- Facet Filter - Simple — With the Facet Filter you can offer multiple filters ('facets') to assist the user in nar…
- Feed Input — This sample shows a standalone feed input with different settings.
- Object Marker in a table — The ObjectMarker is a small building block representing an object by an icon or text and…
- Nav Container — The Nav Container stacks multiple pages and offers an API to switch between them with som…
- Button with Badge — Button with a Badge attached
- Color Palette as popover — The ColorPalette in a popover (by use of thin wrapper control sap.m.ColorPalettePopover).
- Busy Dialog - Light — This is a 'light' version of the standard Busy Dialog; it also blocks the user interface…
- Carousel with Multiple Items at Once — The customLayout aggregation determines how many pages are displayed in Carousel's visibl…
- Date Picker - Value States — This example shows different DatePicker value states.
- Date Range Selection - Value States — This example shows different DateRangeSelection value states.
On this page