Toolbar vs Bar vs OverflowToolbar
Toolbar handles overflow by shrinking items. OverflowToolbar provides an overflow menu. Bar is able to perfectly center a text if nothing overflows.
Z2UI5_CL_SMPC_APP_189
Controls
sap.m
UI5 1.71
The facts
- Repository
- abap2UI5/samples-controls
- Class
Z2UI5_CL_SMPC_APP_189- Source file
z2ui5_cl_smpc_app_189.clas.abap↗- Library
- sap.m
- UI5 entity
sap.m.Bar- Demo kit sample
sap.m.sample.ToolbarVsBar- 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: bar, sap.m, toolbarvsbar, button, toolbar, toolbarspacer, title, messagestrip, label, toolbarlayoutdata, overflowtoolbar
Controls it builds
- sap.m.Bar
- sap.m.Button
- sap.m.Label
- sap.m.MessageStrip
- sap.m.OverflowToolbar
- sap.m.Page
- sap.m.Title
- sap.m.Toolbar
- sap.m.ToolbarLayoutData
- sap.m.ToolbarSpacer
- sap.ui.core.mvc.View
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_189.clas.abap — 203 lines
Click a number to link to a line — shift-click for a range.
Read it on GitHub ↗
" @keywords bar sap.m toolbarvsbar button toolbar toolbarspacer title messagestrip label toolbarlayoutdata overflowtoolbar
" @summary Toolbar handles overflow by shrinking items. OverflowToolbar provides an overflow menu. Bar is able to perfectly center a text if nothing overflows.
CLASS z2ui5_cl_smpc_app_189 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_189 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 = `height` v = `100%`
)->a( n = `xmlns:mvc` v = `sap.ui.core.mvc`
)->a( n = `xmlns` v = `sap.m`
)->ele( `Page`
)->a( n = `title` v = `Bar can center a Title.`
)->a( n = `titleLevel` v = `H2`
)->a( n = `class` v = `sapUiContentPadding`
)->a( n = `showNavButton` v = `true`
)->ele( `headerContent`
)->tag( `Button`
)->a( n = `icon` v = `sap-icon://action`
)->end(
)->ele( `subHeader`
)->ele( `Toolbar`
)->tag( `Button`
)->a( n = `type` v = `Back`
)->a( n = `tooltip` v = `Back`
)->tag( `ToolbarSpacer`
)->tag( `Title`
)->a( n = `text` v = `Toolbar center`
)->a( n = `level` v = `H3`
)->tag( `ToolbarSpacer`
)->end(
)->end(
)->ele( `content`
)->tag( `MessageStrip`
)->a( n = `text` v = `A Toolbar's centering technique will be slightly off the center if there is a button on the left.`
)->a( n = `class` v = `sapUiTinyMargin`
)->ele( `Toolbar`
)->ele( `Label`
)->a( n = `text` v = `Toolbar can shrink content in case of overflow.`
)->ele( `layoutData`
)->tag( `ToolbarLayoutData`
)->a( n = `shrinkable` v = `false`
)->end(
)->end(
)->ele( `Button`
)->a( n = `text` v = `Accept`
)->a( n = `type` v = `Accept`
)->ele( `layoutData`
)->tag( `ToolbarLayoutData`
)->a( n = `shrinkable` v = `true`
)->end(
)->end(
)->ele( `Label`
)->a( n = `text` v = `This is a long non-shrinkable label.`
)->ele( `layoutData`
)->tag( `ToolbarLayoutData`
)->a( n = `shrinkable` v = `false`
)->end(
)->end(
)->ele( `Button`
)->a( n = `text` v = `Reject`
)->a( n = `type` v = `Reject`
)->ele( `layoutData`
)->tag( `ToolbarLayoutData`
)->a( n = `shrinkable` v = `true`
)->end(
)->end(
)->ele( `Button`
)->a( n = `text` v = `Big Big Big Big Big Big Big Big Button`
)->ele( `layoutData`
)->tag( `ToolbarLayoutData`
)->a( n = `shrinkable` v = `true`
)->end(
)->end(
)->end(
)->tag( `Label`
)->ele( `Bar`
)->ele( `contentLeft`
)->tag( `Label`
)->a( n = `text` v = `Bar cannot really handle overflow it just cuts the content.`
)->end(
)->ele( `contentMiddle`
)->tag( `Button`
)->a( n = `text` v = `Accept`
)->a( n = `type` v = `Accept`
)->tag( `Label`
)->a( n = `text` v = `This is a long non-shrinkable label.`
)->tag( `Button`
)->a( n = `text` v = `Reject`
)->a( n = `type` v = `Reject`
)->tag( `Button`
)->a( n = `text` v = `Edit`
)->tag( `Button`
)->a( n = `text` v = `Big Big Big Big Big Big Big Big Button`
)->end(
)->end(
)->tag( `Label`
)->ele( `OverflowToolbar`
)->ele( `Label`
)->a( n = `text` v = `OverflowToolbar provides a See more (...) button for overflow.`
)->ele( `layoutData`
)->tag( `ToolbarLayoutData`
)->a( n = `shrinkable` v = `false`
)->end(
)->end(
)->ele( `Button`
)->a( n = `text` v = `Accept`
)->a( n = `type` v = `Accept`
)->ele( `layoutData`
)->tag( `ToolbarLayoutData`
)->a( n = `shrinkable` v = `true`
)->end(
)->end(
)->ele( `Label`
)->a( n = `text` v = `This is a long non-shrinkable label`
)->ele( `layoutData`
)->tag( `ToolbarLayoutData`
)->a( n = `shrinkable` v = `false`
)->end(
)->end(
)->ele( `Button`
)->a( n = `text` v = `Reject`
)->a( n = `type` v = `Reject`
)->ele( `layoutData`
)->tag( `ToolbarLayoutData`
)->a( n = `shrinkable` v = `true`
)->end(
)->end(
)->ele( `Button`
)->a( n = `text` v = `Big Big Big Big Big Big Big Big Button`
)->ele( `layoutData`
)->tag( `ToolbarLayoutData`
)->a( n = `shrinkable` v = `true`
)->end(
)->end(
)->end(
)->end(
)->ele( `footer`
)->ele( `Toolbar`
)->end(
)->end(
)->end( ).
client->view_display( view->stringify( ) ).
ENDMETHOD.
ENDCLASS.
More in sap.m
- Header Container - Vertical Mode — The Header Container with a vertical layout and with divider lines.
- Flex Box - Gap, Row Gap & Column Gap — You can add gap between rows and columns.
- Input - Types — Input type corresponds to the type attribute of the HTML input tag. On touch devices, it…
- Link — Here are some links. Typically links are used in user interfaces to trigger navigation to…
- Toolbar - Responsive — Toolbar items can be displayed depending on the current device.
- Whitespaces Pattern — Renders whitespaces properly within controls
- Flex Box - Render Type — Flex items can be rendered differently. By default, they are wrapped in a div element. Op…
- Object Attribute inside Table — This is an example of Object Attribute used inside Table.
- Combo box - Two columns layout — Use the combo box dropdown list with two columns layout if you need to display additional…
- List - Footer — With the 'footerText' property you can set a message that is shown at the very end of the…
- Object Header - markers aggregation — This sample shows the different states of an Object Header, which can be set using the ma…
- Object List Item - markers aggregation — This sample shows the different states of an Object List Item, which can be set using the…
On this page