Label Properties
This sample shows the different behaviors of a label.
Z2UI5_CL_SMPC_APP_058
Controls
sap.m
UI5 1.71
The facts
- Repository
- abap2UI5/samples-controls
- Class
Z2UI5_CL_SMPC_APP_058- Source file
z2ui5_cl_smpc_app_058.clas.abap↗- Library
- sap.m
- UI5 entity
sap.m.Label- Demo kit sample
sap.m.sample.LabelProperties- 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: label, sap.m, properties:, wrapping, hyphenation, simpleform, switch, slider, scrollcontainer, input, panel, messagestrip
Controls it builds
- sap.m.Input
- sap.m.Label
- sap.m.MessageStrip
- sap.m.Panel
- sap.m.ScrollContainer
- sap.m.Slider
- sap.m.Switch
- sap.ui.core.mvc.View
- sap.ui.layout.form.SimpleForm
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_058.clas.abap — 137 lines
Click a number to link to a line — shift-click for a range.
Read it on GitHub ↗
" @keywords label sap.m properties: wrapping hyphenation simpleform switch slider scrollcontainer input panel messagestrip
" @summary This sample shows the different behaviors of a label.
CLASS z2ui5_cl_smpc_app_058 DEFINITION PUBLIC.
PUBLIC SECTION.
INTERFACES z2ui5_if_app.
DATA display_only TYPE abap_bool.
DATA wrapping TYPE abap_bool.
DATA hyphenation TYPE abap_bool.
DATA slider_value TYPE i.
PROTECTED SECTION.
DATA client TYPE REF TO z2ui5_if_client.
METHODS view_display.
METHODS model_init.
PRIVATE SECTION.
ENDCLASS.
CLASS z2ui5_cl_smpc_app_058 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( ).
ENDIF.
ENDMETHOD.
METHOD view_display.
DATA(view) = z2ui5_cl_ui5_view_builder=>factory( ).
view->ele( n = `View` ns = `mvc`
)->a( n = `xmlns:mvc` v = `sap.ui.core.mvc`
)->a( n = `xmlns` v = `sap.m`
)->a( n = `xmlns:l` v = `sap.ui.layout`
)->a( n = `xmlns:form` v = `sap.ui.layout.form`
)->ele( n = `SimpleForm` ns = `form`
)->a( n = `layout` v = `ResponsiveGridLayout`
)->a( n = `editable` v = `true`
)->a( n = `title` v = `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 = `Display Only`
" roundtrip-free rework: the controller handlers are replaced by two-way bindings, the change and liveChange events dropped (see sidecar)
)->tag( `Switch`
)->a( n = `state` v = client->_bind( display_only )
)->tag( `Label`
)->a( n = `text` v = `Wrapping`
)->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( hyphenation )
)->tag( `Label`
)->a( n = `text` v = `Container Width`
)->tag( `Slider`
)->a( n = `value` v = client->_bind( slider_value )
)->end(
)->ele( `ScrollContainer`
)->a( n = `id` v = `containerForm`
)->a( n = `width` v = |\{= ${ client->_bind( slider_value ) } + '%'\}|
)->a( n = `horizontal` v = `false`
)->a( n = `vertical` v = `false`
)->ele( n = `SimpleForm` ns = `form`
)->a( n = `layout` v = `ResponsiveGridLayout`
)->a( n = `editable` v = `true`
)->a( n = `title` v = `Result in a Form`
)->tag( `Label`
)->a( n = `id` v = `labelInForm`
)->a( n = `displayOnly` v = client->_bind( display_only )
)->a( n = `wrapping` v = client->_bind( wrapping )
)->a( n = `wrappingType` v = |\{= ${ client->_bind( hyphenation ) } ? 'Hyphenated' : 'Normal'\}|
)->a( n = `text` v = `Labels are used as titles [long test word] forsinglecontrolsorgroups of controls. Label appearance can be influenced by properties`
)->tag( `Input`
)->end(
)->end(
)->ele( `Panel`
)->a( n = `id` v = `containerLayout`
)->a( n = `headerText` v = `Result in a Container`
)->a( n = `width` v = |\{= ${ client->_bind( slider_value ) } + '%'\}|
)->tag( `Label`
)->a( n = `id` v = `label`
)->a( n = `labelFor` v = `containerInput`
)->a( n = `displayOnly` v = client->_bind( display_only )
)->a( n = `wrapping` v = client->_bind( wrapping )
)->a( n = `wrappingType` v = |\{= ${ client->_bind( hyphenation ) } ? 'Hyphenated' : 'Normal'\}|
)->a( n = `text` v = `Labels are used as titles [long test word] forsinglecontrolsorgroups of controls. Label appearance can be influenced by properties`
)->tag( `Input`
)->a( n = `id` v = `containerInput`
)->end(
)->tag( `MessageStrip`
)->a( n = `type` v = `Warning`
)->a( n = `text` v = `Note: Hyphenation is not possible when Wrapping is set to 'false'`
)->a( n = `class` v = `sapUiSmallMarginBeginEnd sapUiSmallMarginTopBottom` ).
client->view_display( view->stringify( ) ).
ENDMETHOD.
METHOD model_init.
display_only = abap_true.
wrapping = abap_true.
hyphenation = abap_false.
slider_value = 100.
ENDMETHOD.
ENDCLASS.
More in sap.m
- Text Area — The Text Area allows to enter multi-line text and automatically breaks to a new line for…
- Toolbar - Shrinkable items — Toolbar items can shrink/expand when the toolbar is resized. This behavior is enabled/dis…
- Tree - Basic — Tree displays data in hierarchical structure.
- Standalone Icon Tab Header — Icon Tab Header used standalone, outside of Icon Tab Bar.
- ImageContent — Shows ImageContent that can include an icon, a profile image, or a logo with a tooltip.
- Input List Item — Use the Input List Item on phones to build form like user interfaces.
- LightBox — Displays several image thumbnails. Clicking on each of them will open a LightBox.
- Menu — This control is used to show a menu in both desktop and mobile.
- Menu Button — This control is used to open a menu in both desktop and mobile.
- Message Strip with enableFormattedText — A sample MessageStrip that shows status messages with additional formatting.
- News Content — This control is used to display the news content text and subheader in a tile.
- Numeric Content with Icon — Shows NumericContent including an icon.
On this page