abap2UI5

Title Properties

This sample shows the different behaviors of a title.

Z2UI5_CL_SMPC_APP_418

Controls sap.m UI5 1.71

The facts

Repository
abap2UI5/samples-controls
Class
Z2UI5_CL_SMPC_APP_418
Source file
z2ui5_cl_smpc_app_418.clas.abap
Library
sap.m
UI5 entity
sap.m.Title
Demo kit sample
sap.m.sample.TitleWrapping
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: title, sap.m, titlewrapping, simpleform, label, switch, slider, panel, messagestrip

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_418.clas.abap — 98 lines Read it on GitHub ↗
" @keywords title sap.m titlewrapping simpleform label switch slider panel messagestrip
" @summary This sample shows the different behaviors of a title.
CLASS z2ui5_cl_smpc_app_418 DEFINITION PUBLIC.

  PUBLIC SECTION.
    INTERFACES z2ui5_if_app.

    DATA wrapping  TYPE abap_bool VALUE abap_true.
    DATA hyphenate TYPE abap_bool.
    DATA width_pct TYPE i VALUE 100.

  PROTECTED SECTION.
    DATA client TYPE REF TO z2ui5_if_client.

    METHODS view_display.

  PRIVATE SECTION.
ENDCLASS.


CLASS z2ui5_cl_smpc_app_418 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( ).

    view->ele( n = `View` ns = `mvc`
        )->a( n = `xmlns`        v = `sap.m`
        )->a( n = `xmlns:mvc`    v = `sap.ui.core.mvc`
        )->a( n = `xmlns:f`      v = `sap.ui.layout.form`
        )->a( n = `displayBlock` v = `true`

        )->ele( n = `SimpleForm` ns = `f`
            )->a( n = `layout`          v = `ResponsiveGridLayout`
            )->a( n = `editable`        v = `true`
            )->a( n = `title`           v = `Title Properties`
            )->a( n = `adjustLabelSpan` v = `false`
            )->a( n = `labelSpanXL`     v = `2`
            )->a( n = `labelSpanL`      v = `2`
            )->a( n = `labelSpanM`      v = `2`
            )->a( n = `labelSpanS`      v = `5`

            )->tag( `Label`
                )->a( n = `text` v = `Wrapping`
            " onWrappingChange toggles Title.wrapping - reproduced roundtrip-free by
            " two-way binding the same flag on both controls (the change wire is dropped)
            )->tag( `Switch`
                )->a( n = `id`    v = `wrappingSwitch`
                )->a( n = `state` v = client->_bind( wrapping )
            )->tag( `Label`
                )->a( n = `text` v = `Enable Hyphenation`
            )->tag( `Switch`
                )->a( n = `state` v = client->_bind( hyphenate )
            )->tag( `Label`
                )->a( n = `text` v = `Container Width`
            " onSliderMoved sets the Panel width to value+'%' - the liveChange wire is
            " dropped, the Panel width follows the bound value in an expression binding
            )->tag( `Slider`
                )->a( n = `id`    v = `widthSlider`
                )->a( n = `value` v = client->_bind( width_pct )

        )->end(

        )->ele( `Panel`
            )->a( n = `id`         v = `containerLayout`
            )->a( n = `headerText` v = `Rendered Title in container`
            )->a( n = `width`      v = |\{= ${ client->_bind( width_pct ) } + '%' \}|

            )->tag( `Title`
                )->a( n = `id`           v = `WrappingTitle`
                )->a( n = `wrapping`     v = client->_bind( wrapping )
                " onHyphenationChange: wrappingType follows the second Switch
                )->a( n = `wrappingType` v = |\{= ${ client->_bind( hyphenate ) } ? 'Hyphenated' : 'Normal' \}|
                )->a( n = `text`         v = `The Title control represents a single line of text with explicit header / title semantics. ` &&
                                             `The Title control represents a single line of text with explicit header / title semantics.`

        )->end(

        )->tag( `MessageStrip`
            )->a( n = `class` v = `sapUiSmallMarginBeginEnd sapUiSmallMarginTopBottom`
            )->a( n = `type`  v = `Warning`
            )->a( n = `text`  v = `Note: Hyphenation is not possible when Wrapping is set to "false"` ).

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

  ENDMETHOD.

ENDCLASS.

More in sap.m

Search every abap2UI5 sample · the full list on one page

On this page