Input - Value States
This example shows different input value states.
- Class
z2ui5_cl_smpc_app_032- Repository
- abap2UI5/samples-controls
- Ports
sap.m.sample.InputValueState- UI5 libraries
- sap.m, sap.ui.core
- Lowest UI5 release
- 1.94
- In the browser
- Runs in the playground
- Controls it builds
- sap.m.FormattedText, sap.m.Input, sap.m.Link, sap.m.VBox, sap.ui.core.mvc.View
The class
" @keywords input sap.m shows different value vbox formattedtext link
" @summary This example shows different input value states.
" @origin sap.m.sample.InputValueState - https://sdk.openui5.org/entity/sap.m.Input/sample/sap.m.sample.InputValueState (status: reviewed - read against the original, not run)
CLASS z2ui5_cl_smpc_app_032 DEFINITION PUBLIC.
PUBLIC SECTION.
INTERFACES z2ui5_if_app.
PROTECTED SECTION.
DATA client TYPE REF TO z2ui5_if_client.
METHODS view_display.
METHODS on_event.
PRIVATE SECTION.
ENDCLASS.
CLASS z2ui5_cl_smpc_app_032 IMPLEMENTATION.
METHOD z2ui5_if_app~main.
me->client = client.
IF client->check_on_navigated( ).
view_display( ).
ELSEIF client->check_on_event( ).
on_event( ).
ENDIF.
ENDMETHOD.
METHOD view_display.
DATA(warning_text) = `Warning message. Extra long text used as a warning message. Extra long text used as a warning message - 2. ` &&
`Extra long text used as a warning message - 3. Extra long text used as a warning message - 4. ` &&
`Extra long text used as a warning message - 5.`.
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`
)->ele( `VBox`
)->a( n = `class` v = `sapUiSmallMargin`
)->tag( `Input`
)->a( n = `value` v = `Value state None`
)->a( n = `class` v = `sapUiSmallMarginTopBottom`
)->tag( `Input`
)->a( n = `showClearIcon` v = `true`
)->a( n = `valueState` v = `Success`
)->a( n = `value` v = `Value state Success`
)->a( n = `class` v = `sapUiSmallMarginTopBottom`
)->tag( `Input`
)->a( n = `showClearIcon` v = `true`
)->a( n = `valueState` v = `Warning`
)->a( n = `valueStateText` t = warning_text
)->a( n = `value` v = `Value state Warning.`
)->a( n = `class` v = `sapUiSmallMarginTopBottom`
)->ele( `Input`
)->a( n = `showClearIcon` v = `true`
)->a( n = `valueState` v = `Warning`
)->a( n = `value` v = `Value state Warning with message containing a link.`
)->a( n = `class` v = `sapUiSmallMarginTopBottom`
)->ele( `formattedValueStateText`
)->ele( `FormattedText`
)->a( n = `htmlText` v = `There is a conflict with the current value. Recommendation based on: %%0`
)->ele( `controls`
)->tag( `Link`
)->a( n = `text` v = `See more information`
)->a( n = `href` v = ``
)->a( n = `press` v = client->_event( `LINK_PRESS` )
)->end(
)->end(
)->end(
)->end(
)->tag( `Input`
)->a( n = `valueState` v = `Error`
)->a( n = `value` v = `Value state Error`
)->a( n = `class` v = `sapUiSmallMarginTopBottom`
)->tag( `Input`
)->a( n = `valueState` v = `Information`
)->a( n = `value` v = `Value state Information`
)->a( n = `class` v = `sapUiSmallMarginTopBottom`
)->ele( `Input`
)->a( n = `valueState` v = `Information`
)->a( n = `value` v = `Value state Information with message containing multiple links.`
)->a( n = `class` v = `sapUiSmallMarginTopBottom`
)->ele( `formattedValueStateText`
)->ele( `FormattedText`
)->a( n = `htmlText` v = `Recommendation based on: %%0 and %%1.`
)->ele( `controls`
)->tag( `Link`
)->a( n = `text` v = `link 1`
)->a( n = `press` v = client->_event( `LINK_PRESS` )
)->tag( `Link`
)->a( n = `text` v = `link 2`
)->a( n = `press` v = client->_event( `LINK_PRESS` )
)->end(
)->end(
)->end(
)->end(
)->end( ).
client->view_display( view->stringify( ) ).
ENDMETHOD.
METHOD on_event.
IF client->get_event( ) = `LINK_PRESS`.
" docked at CenterCenter 1:1 - my/at are sap.m.MessageToast options, so
" they are set on the control: the whitelisted global call takes the
" option object of MessageToast.show( ) as its last argument
client->follow_up_action(
val = client->cs_event-control_global
t_arg = VALUE #( ( `MESSAGE_TOAST` )
( `show` )
( `You have pressed a link in value state message` )
( `{"my":"center center","at":"center center"}` ) ) ).
ENDIF.
ENDMETHOD.
ENDCLASS.