Object Attribute
This is an example of Object Attribute used standalone.
Z2UI5_CL_SMPC_APP_073
Controls
sap.m
UI5 1.97
The facts
- Repository
- abap2UI5/samples-controls
- Class
Z2UI5_CL_SMPC_APP_073- Source file
z2ui5_cl_smpc_app_073.clas.abap↗- Library
- sap.m
- UI5 entity
sap.m.ObjectAttribute- Demo kit sample
sap.m.sample.ObjectAttributes- SAP's own sample
- running at sdk.openui5.org ↗
- Minimum UI5
- 1.97
- In the playground
- runs in the browser, with no system and nothing installed
Keywords: objectattribute, object, attribute, sap.m, active, attributes, customcontent, verticallayout, label, link, text, dialog
Controls it builds
- sap.m.Button
- sap.m.Dialog
- sap.m.Label
- sap.m.Link
- sap.m.ObjectAttribute
- sap.m.RatingIndicator
- sap.m.Text
- sap.m.TextArea
- sap.ui.core.FragmentDefinition
- sap.ui.core.mvc.View
- sap.ui.layout.VerticalLayout
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_073.clas.abap — 216 lines
Click a number to link to a line — shift-click for a range.
Read it on GitHub ↗
" @keywords objectattribute object attribute sap.m active attributes customcontent verticallayout label link text dialog
" @summary This is an example of Object Attribute used standalone.
CLASS z2ui5_cl_smpc_app_073 DEFINITION PUBLIC.
PUBLIC SECTION.
INTERFACES z2ui5_if_app.
TYPES:
BEGIN OF ty_s_product,
weight_measure TYPE string,
weight_unit TYPE string,
width TYPE string,
depth TYPE string,
height TYPE string,
dim_unit TYPE string,
END OF ty_s_product.
DATA s_product TYPE ty_s_product.
PROTECTED SECTION.
DATA client TYPE REF TO z2ui5_if_client.
METHODS view_display.
METHODS on_event.
METHODS model_init.
PRIVATE SECTION.
ENDCLASS.
CLASS z2ui5_cl_smpc_app_073 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( ).
ELSEIF client->check_on_event( ).
on_event( ).
ENDIF.
ENDMETHOD.
METHOD view_display.
DATA(view) = z2ui5_cl_ui5_view_builder=>factory( ).
view->ele( n = `View` ns = `mvc`
)->a( n = `xmlns:l` v = `sap.ui.layout`
)->a( n = `xmlns:mvc` v = `sap.ui.core.mvc`
)->a( n = `xmlns` v = `sap.m`
)->ele( n = `VerticalLayout` ns = `l`
)->a( n = `class` v = `sapUiContentPadding`
)->a( n = `width` v = `100%`
)->ele( n = `content` ns = `l`
)->tag( `Label`
)->a( n = `text` v = `Not active Object Attribute with title and text`
)->a( n = `design` v = `Bold`
)->a( n = `class` v = `sapUiSmallMarginTop`
" element binding kept 1:1 - a one-record structure S_PRODUCT instead of ProductCollection record 0 (see sidecar)
)->tag( `ObjectAttribute`
)->a( n = `binding` v = client->_bind( s_product )
)->a( n = `title` v = `Weight`
)->a( n = `text` v = `{WEIGHT_MEASURE} {WEIGHT_UNIT}`
)->tag( `Label`
)->a( n = `text` v = `Not active Object Attribute only with set text`
)->a( n = `design` v = `Bold`
)->a( n = `class` v = `sapUiSmallMarginTop`
)->tag( `ObjectAttribute`
)->a( n = `binding` v = client->_bind( s_product )
)->a( n = `text` v = `{WIDTH} x {DEPTH} x {HEIGHT} {DIM_UNIT}`
)->tag( `Label`
)->a( n = `text` v = `Active Object Attribute with title and text which opens popup on press`
)->a( n = `design` v = `Bold`
)->a( n = `class` v = `sapUiSmallMarginTop`
)->tag( `ObjectAttribute`
)->a( n = `title` v = `Click to`
)->a( n = `text` v = `Provide feedback`
)->a( n = `active` v = `true`
" POST-1.71: ariaHasPopup (since UI5 1.97) kept 1:1
)->a( n = `ariaHasPopup` v = `Dialog`
)->a( n = `press` v = client->_event( `FEEDBACK` )
)->tag( `Label`
)->a( n = `text` v = `Active Object Attribute with title and text which opens link on press`
)->a( n = `design` v = `Bold`
)->a( n = `class` v = `sapUiSmallMarginTop`
)->tag( `ObjectAttribute`
)->a( n = `title` v = `Visit our site`
)->a( n = `text` v = `www.sap.com`
)->a( n = `active` v = `true`
" the original handleSAPLinkPressed - URLHelper redirect as the URLHELPER REDIRECT frontend action (see sidecar)
)->a( n = `press` v = client->follow_up_action( val = client->cs_event-urlhelper
t_arg = VALUE #( ( `REDIRECT` ) ( |\{ URL: 'http://www.sap.com', NEW_WINDOW: true \}| ) ) )
)->tag( `Label`
)->a( n = `text` v = `Active Object Attribute which has only title, therefore no link is displayed`
)->a( n = `design` v = `Bold`
)->a( n = `class` v = `sapUiSmallMarginTop`
)->tag( `ObjectAttribute`
)->a( n = `title` v = `Created by`
)->a( n = `active` v = `true`
)->a( n = `press` v = client->_event( `FEEDBACK` )
)->tag( `Label`
)->a( n = `text` v = `Active Object Attribute with long title and long text which will truncate and occupy 50% each`
)->a( n = `design` v = `Bold`
)->a( n = `class` v = `sapUiSmallMarginTop`
)->tag( `ObjectAttribute`
)->a( n = `title` v = `Some very long title that will strat to truncate on smaller screen`
)->a( n = `text` v = `Some very long text that will strat to truncate on smaller screen`
)->a( n = `active` v = `true`
)->tag( `Label`
)->a( n = `text` v = `Object Attribute with customContent aggregation containing sap.m.Link`
)->a( n = `design` v = `Bold`
)->a( n = `class` v = `sapUiSmallMarginTop`
)->ele( `ObjectAttribute`
)->a( n = `title` v = `Custom content`
)->ele( `customContent`
)->tag( `Link`
)->a( n = `text` v = `this is sap.m.Link`
)->end(
)->end(
)->tag( `Label`
)->a( n = `text` v = `Object Attribute with customContent aggregation containing sap.m.Text`
)->a( n = `design` v = `Bold`
)->a( n = `class` v = `sapUiSmallMarginTop`
)->ele( `ObjectAttribute`
)->a( n = `title` v = `Custom content`
)->ele( `customContent`
)->tag( `Text`
)->a( n = `text` v = `some text set inside sap.m.Text`
)->end(
)->end(
)->end(
)->end( ).
client->view_display( view->stringify( ) ).
ENDMETHOD.
METHOD on_event.
CASE client->get_event( ).
WHEN `FEEDBACK`.
" the original's handleFeedbacklinkPressed - a Dialog with a RatingIndicator + TextArea and Submit/Cancel
DATA(popup) = z2ui5_cl_ui5_view_builder=>factory( ).
popup->ele( n = `FragmentDefinition` ns = `core`
)->a( n = `xmlns` v = `sap.m`
)->a( n = `xmlns:core` v = `sap.ui.core`
)->ele( `Dialog`
)->a( n = `title` v = `Provide feedback`
)->a( n = `class` v = `sapUiContentPadding`
)->tag( `RatingIndicator`
)->a( n = `maxValue` v = `5`
)->tag( `TextArea`
)->a( n = `placeholder` v = `What do you think about this item?`
)->a( n = `rows` v = `5`
)->a( n = `cols` v = `30`
)->a( n = `width` v = `100%`
)->ele( `beginButton`
)->tag( `Button`
)->a( n = `text` v = `Submit`
)->a( n = `type` v = `Accept`
)->a( n = `press` v = client->_event( `SUBMIT` )
)->end(
)->ele( `endButton`
)->tag( `Button`
)->a( n = `text` v = `Cancel`
)->a( n = `type` v = `Reject`
)->a( n = `press` v = client->follow_up_action( client->cs_event-popup_close )
)->end(
)->end( ).
client->popup_display( popup->stringify( ) ).
WHEN `SUBMIT`.
" the original toasts on the STILL-OPEN dialog and closes it from the
" toast's onClose, so the order is toast first, close after - only the
" 2s setBusy delay in front of it stays dropped
client->message_toast_display( text = `Feedback sent.`
duration = `2000`
my = `center center`
at = `center center`
onclose = `FEEDBACK_CLOSED` ).
WHEN `FEEDBACK_CLOSED`.
client->popup_destroy( ).
ENDCASE.
ENDMETHOD.
METHOD model_init.
" the bound record /ProductCollection/0 (Notebook Basic 15) of ui5/mock/products.json, verbatim
s_product = VALUE #( weight_measure = `4.2` weight_unit = `KG`
width = `30` depth = `18`
height = `3` dim_unit = `cm` ).
ENDMETHOD.
ENDCLASS.
More in sap.m
- Message Popover - Async Message Handling — The message handling concept sample shows how you can use callback functions for resolvin…
- Slider — With the Slider a user can choose a value from a numerical range.
- Radio Button — Typically the Radio Button is used by other controls. E.g. the List uses it for the singl…
- Progress Indicator — Shows the progress of a process in a graphical way. To indicate the progress, the inside…
- Object Identifier — The object identifier is a small building block representing an object by a title and sho…
- Object Number — The object number is a small building block representing an important, numerical attribut…
- Object List Item — The Object List Item has many possibilities to provide a quick overview for an object wit…
- SelectList — A SelectList allows the user to select one item from a list of choices.
- Notification List Item — A list item suitable for showing notifications to the user.
- Notification List Group — A control suitable for grouping notifications.
- Tile Content — Shows the universal container for different content types and context information in the…
- Title with Link — This sample shows how to add a link to a title.
On this page