Image
Images are faster than words and attract people's attention. Images can also have an active state or be used in SVG format.
Z2UI5_CL_SMPC_APP_399
Controls
sap.m
UI5 1.79
The facts
- Repository
- abap2UI5/samples-controls
- Class
Z2UI5_CL_SMPC_APP_399- Source file
z2ui5_cl_smpc_app_399.clas.abap↗- Library
- sap.m
- UI5 entity
sap.m.Image- Demo kit sample
sap.m.sample.Image- SAP's own sample
- running at sdk.openui5.org ↗
- Minimum UI5
- 1.79
- In the playground
- runs in the browser, with no system and nothing installed
Keywords: image, sap.m, vbox, hbox, text
Controls it builds
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_399.clas.abap — 106 lines
Click a number to link to a line — shift-click for a range.
Read it on GitHub ↗
" @keywords image sap.m vbox hbox text
" @summary Images are faster than words and attract people's attention. Images can also have an active state or be used in SVG format.
CLASS z2ui5_cl_smpc_app_399 DEFINITION PUBLIC.
PUBLIC SECTION.
INTERFACES z2ui5_if_app.
PROTECTED SECTION.
DATA client TYPE REF TO z2ui5_if_client.
METHODS view_display.
PRIVATE SECTION.
ENDCLASS.
CLASS z2ui5_cl_smpc_app_399 IMPLEMENTATION.
METHOD z2ui5_if_app~main.
me->client = client.
IF client->check_on_navigated( ).
view_display( ).
ENDIF.
ENDMETHOD.
METHOD view_display.
DATA(view) = z2ui5_cl_ui5_view_builder=>factory( ).
" the controller's imageWidth is Device.system.phone ? 5em : 10em - kept a
" branch over the framework's device> model instead of resolving it at init
DATA(image_width) = `{= ${device>/system/phone} ? '5em' : '10em' }`.
" fixed values of the original models: img>/products/pic1, pic3 and the
" sample's own images/sap-logo.svg
DATA(pic1) = `https://sdk.openui5.org/test-resources/sap/ui/documentation/sdk/images/HT-7777-large.jpg`.
DATA(pic3) = `https://sdk.openui5.org/test-resources/sap/ui/documentation/sdk/images/HT-6100-large.jpg`.
" sap.ui.require.toUrl( 'sap/m/sample/Image/images/sap-logo.svg' ) resolves
" against the demo kit's own layout, which inserts a demokit/ segment - the
" file is at src/sap.m/test/sap/m/demokit/sample/Image/images/. Without it
" both SVG Images 404, and nothing catches that: the e2e smoke resolves only
" /resources/ paths locally and ignores every other miss. Same shape as app
" 288's sample.pdf.
DATA(svg_logo) = `https://sdk.openui5.org/test-resources/sap/m/demokit/sample/Image/images/sap-logo.svg`.
view->ele( n = `View` ns = `mvc`
)->a( n = `xmlns:mvc` v = `sap.ui.core.mvc`
)->a( n = `xmlns` v = `sap.m`
)->ele( `VBox`
)->a( n = `class` v = `sapUiSmallMarginTopBottom sapUiLargeMarginBeginEnd`
)->ele( `HBox`
)->a( n = `justifyContent` v = `SpaceBetween`
)->ele( `VBox`
)->tag( `Text`
)->a( n = `text` v = `Image:`
)->a( n = `class` v = `sapUiSmallMarginBottom`
)->tag( `Image`
)->a( n = `src` v = pic1
)->a( n = `width` v = image_width
)->end(
)->ele( `VBox`
)->tag( `Text`
)->a( n = `id` v = `detailsActiveImage`
)->a( n = `text` v = `Active state image:`
)->a( n = `class` v = `sapUiSmallMarginBottom`
)->tag( `Image`
" ariaDetails is newer than the 1.71 floor - kept for the 1:1 port (POST_171)
)->a( n = `ariaDetails` v = `detailsActiveImage`
)->a( n = `src` v = pic3
)->a( n = `width` v = image_width
)->a( n = `decorative` v = `false`
)->a( n = `press` v = client->follow_up_action( val = client->cs_event-control_global
t_arg = VALUE #( ( `MESSAGE_TOAST` ) ( `show` ) ( `The image has been pressed` ) ) )
)->end(
)->ele( `VBox`
)->tag( `Text`
)->a( n = `text` v = `Image using SVG format:`
)->a( n = `class` v = `sapUiSmallMarginBottom`
)->tag( `Image`
)->a( n = `src` v = svg_logo
)->end(
)->ele( `VBox`
)->tag( `Text`
)->a( n = `text` v = `Image displaying inline SVG:`
)->a( n = `class` v = `sapUiSmallMarginBottom`
)->tag( `Image`
)->a( n = `src` v = svg_logo
" POST-1.71: sap.m.ImageMode.InlineSvg. The enum VALUE
" carries no @since of its own, so no gate can see it -
" measured against the tags instead: at 1.71.0 ImageMode
" has only Image and Background
)->a( n = `mode` v = `InlineSvg` ).
client->view_display( view->stringify( ) ).
ENDMETHOD.
ENDCLASS.
More in sap.m
- Flex Box - Direction & Order — You can influence the direction and order of elements in horizontal and vertical Flex Box…
- Flex Box - Opposing Alignment — In this Flex Box the items are aligned at opposing ends of the container with justifyCont…
- Placing a Title in OverflowToolbar/Toolbar — The sap.m.Title control can be used to place a title inside an OverflowToolbar/Toolbar.
- OverflowToolbar - Alignment — OverflowToolbar and Toolbar are often used for left/right alignment. This is easily achie…
- Panel — Panels are helpful to group custom content. They can be decorated with header and info to…
- Carousel — A sample of a Carousel that contains images.
- Object Header - with Circle-shaped Image — An Object Header can set shape of the image by using 'imageShape' property. The shapes co…
- Time Picker - Value States — This example shows different TimePicker value states.
- Flexible sizing - Toolbar — This page shows flexible sizing with a Toolbar. The upper part extends with its content…
- Flexible sizing - Icon Tab Bar — This page shows flexible sizing with an Icon Tab Bar: The upper part extends with its con…
- Title Properties — This sample shows the different behaviors of a title.
- Menu with Selectable Items — Some menu items can be added to groups to allow single or multiple item selection.
On this page