Samples / Controls / sap.m

Carousel

A sample of a Carousel that contains images.

Class
z2ui5_cl_smpc_app_398
Repository
abap2UI5/samples-controls
Ports
sap.m.sample.Carousel
UI5 libraries
sap.m, sap.ui.core
Lowest UI5 release
1.125
In the browser
Runs in the playground
Controls it builds
sap.m.Carousel, sap.m.Image, sap.m.Title, sap.ui.core.mvc.View

The class

" @keywords carousel sap.m title image
" @summary A sample of a Carousel that contains images.
" @origin sap.m.sample.Carousel - https://sdk.openui5.org/entity/sap.m.Carousel/sample/sap.m.sample.Carousel (status: reviewed - read against the original, not run)
CLASS z2ui5_cl_smpc_app_398 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_398 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( ).

    " fixed values of the original img JSONModel (img>/products/pic1..pic3, screw)
    DATA(base) = `https://sdk.openui5.org/test-resources/sap/ui/documentation/sdk/images/`.

    view->ele( n = `View` ns = `mvc`
        )->a( n = `xmlns`     v = `sap.m`
        )->a( n = `xmlns:l`   v = `sap.ui.layout`
        )->a( n = `xmlns:mvc` v = `sap.ui.core.mvc`
        )->a( n = `height`    v = `100%`

        )->ele( `Title`
            )->a( n = `id`    v = `carouselTitle`
            )->a( n = `class` v = `sapUiSmallMarginTop`
            )->a( n = `text`  v = `Image Gallery Carousel`

        )->end(

        )->ele( `Carousel`
            )->a( n = `ariaLabelledBy` v = `carouselTitle`
            )->a( n = `class`          v = `sapUiContentPadding`
            )->a( n = `loop`           v = `true`

            )->tag( `Image`
                )->a( n = `src` t = base && `HT-7777-large.jpg`
                )->a( n = `alt` v = `Example picture of speakers`
            )->tag( `Image`
                )->a( n = `src` t = base && `HT-6120-large.jpg`
                )->a( n = `alt` v = `Example picture of USB flash drive`
            )->tag( `Image`
                )->a( n = `src` t = base && `HT-6100-large.jpg`
                )->a( n = `alt` v = `Example picture of spotlight`
            )->tag( `Image`
                )->a( n = `src` t = base && `screw.jpg`
                )->a( n = `alt` v = `Example picture of screw` ).

    client->view_display( view->stringify( ) ).

  ENDMETHOD.

ENDCLASS.