Navigation
The next view arrives with a page transition - slide, baseSlide, fade, flip or show - and every way back plays it reversed: nav_app_leave, the browser Back button, an app's own Previous step.
Z2UI5_CL_SMP_APP_531
Learn
Navigation
UI5 1.71
The facts
- Repository
- abap2UI5/samples
- Class
Z2UI5_CL_SMP_APP_531- Source file
z2ui5_cl_smp_app_531.clas.abap↗- Category
- Navigation
- Learning path
- Move through the app
- 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: transition, animation, slide, fade, flip, navcontainer, transition_back, nav_app_leave
Controls it builds
- sap.m.Button
- sap.m.HBox
- sap.m.Label
- sap.m.MessageStrip
- sap.m.Page
- sap.m.Shell
- sap.m.Switch
- sap.m.Title
- sap.m.VBox
- 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_smp_app_531.clas.abap — 129 lines
Click a number to link to a line — shift-click for a range.
Read it on GitHub ↗
" @keywords transition animation slide fade flip navcontainer transition_back nav_app_leave
" @summary The next view arrives with a page transition - slide, baseSlide, fade, flip or show - and every way back plays it reversed: nav_app_leave, the browser Back button, an app's own Previous step.
"! The page transitions of client->view_display( transition = ... ). Every
"! button opens the page z2ui5_cl_smp_app_532 with one transition; the way
"! back plays it reversed - the rule of sap.m.NavContainer: the page being
"! left runs the way it ARRIVED, backwards. Two more entries show the cases
"! the framework cannot tell by itself, or tells without being asked: an app
"! with screens of its own (z2ui5_cl_smp_app_533, transition_back), and the
"! browser Back and Forward buttons under hash routing.
CLASS z2ui5_cl_smp_app_531 DEFINITION PUBLIC.
PUBLIC SECTION.
INTERFACES z2ui5_if_app.
" hash routing (KEEP), switched with the Switch - the browser buttons
" then move between the pages as well, with the same transitions
DATA routing TYPE abap_bool.
PROTECTED SECTION.
DATA client TYPE REF TO z2ui5_if_client.
METHODS view_display.
PRIVATE SECTION.
ENDCLASS.
CLASS z2ui5_cl_smp_app_531 IMPLEMENTATION.
METHOD z2ui5_if_app~main.
me->client = client.
" this app names no transition of its own: a way back TO it plays what
" the page being left arrived with
IF client->check_on_navigated( ).
view_display( ).
ELSEIF client->check_on_event( `GO` ).
client->nav_app_call( z2ui5_cl_smp_app_532=>factory( transition = client->get_event_arg( ) level = 1 ) ).
ELSEIF client->check_on_event( `WIZARD` ).
client->nav_app_call( NEW z2ui5_cl_smp_app_533( ) ).
ELSEIF client->check_on_event( `ROUTING` ).
" the Switch wrote the new state before main( ) ran
DATA(mode) = COND string( WHEN routing = abap_true THEN client->cs_nav_mode-keep ELSE client->cs_nav_mode-default ).
client->follow_up_action( val = client->cs_event-hash_routing t_arg = VALUE #( ( mode ) ) ).
ENDIF.
ENDMETHOD.
METHOD view_display.
DATA(view) = z2ui5_cl_ui5_view_builder=>factory(
)->ele( n = `View` ns = `mvc`
)->a( n = `displayBlock` v = `true`
)->a( n = `height` v = `100%`
)->a( n = `xmlns` v = `sap.m`
)->a( n = `xmlns:mvc` v = `sap.ui.core.mvc` ).
DATA(page) = view->ele( `Shell`
)->ele( `Page`
)->a( n = `title` v = `abap2UI5 - Navigation - Page Transitions (view_display transition)`
)->a( n = `showNavButton` b = client->check_app_prev_stack( )
)->a( n = `navButtonPress` v = client->_event_nav_app_leave( ) ).
page->tag( `MessageStrip`
)->a( n = `text` v = `Each button opens a page with one transition. Leave that page with the nav button in ` &&
`its header: the transition plays reversed - the page being left runs the way it arrived, ` &&
`backwards, as in sap.m.NavContainer. baseSlide needs UI5 1.74, older releases play slide.`
)->a( n = `type` v = `Information`
)->a( n = `showIcon` b = abap_true
)->a( n = `class` v = `sapUiSmallMargin` ).
DATA(content) = page->ele( `VBox`
)->a( n = `class` v = `sapUiSmallMargin` ).
content->tag( `Title`
)->a( n = `text` v = `view_display( transition = ... )`
)->a( n = `level` v = `H2` ).
DATA(buttons) = content->ele( `HBox`
)->a( n = `wrap` v = `Wrap`
)->a( n = `class` v = `sapUiSmallMarginTop` ).
" the five cs_transition names, and none at all to compare with
DATA(t_transition) = VALUE string_table( ( client->cs_transition-slide )
( client->cs_transition-base_slide )
( client->cs_transition-fade )
( client->cs_transition-flip )
( client->cs_transition-show )
( `` ) ).
LOOP AT t_transition INTO DATA(transition).
DATA(name) = COND string( WHEN transition IS INITIAL THEN `none` ELSE transition ).
buttons->tag( `Button`
)->a( n = `id` t = |go-{ name }|
)->a( n = `text` t = name
)->a( n = `icon` v = `sap-icon://navigation-right-arrow`
)->a( n = `class` v = `sapUiTinyMarginEnd sapUiTinyMarginBottom`
)->a( n = `press` v = client->_event( val = `GO` arg = transition ) ).
ENDLOOP.
content->tag( `Title`
)->a( n = `text` v = `More`
)->a( n = `level` v = `H3`
)->a( n = `class` v = `sapUiMediumMarginTop` ).
content->tag( `Button`
)->a( n = `id` v = `wizard`
)->a( n = `text` v = `An app with screens of its own - Next and Previous (transition_back)`
)->a( n = `icon` v = `sap-icon://step`
)->a( n = `class` v = `sapUiTinyMarginBottom`
)->a( n = `press` v = client->_event( `WIZARD` ) ).
content->ele( `HBox`
)->a( n = `alignItems` v = `Center`
)->tag( `Switch`
)->a( n = `id` v = `routing`
)->a( n = `state` v = client->_bind( routing )
)->a( n = `change` v = client->_event( `ROUTING` )
)->tag( `Label`
)->a( n = `text` v = `Hash routing (KEEP) - the browser Back and Forward buttons move the pages too`
)->a( n = `class` v = `sapUiTinyMarginBegin` ).
client->view_display( view->stringify( ) ).
ENDMETHOD.
ENDCLASS.
More in Navigation
- Navigation — Call and Leave Apps (nav_app_call)
- Navigation — Data Loss Protection on Leaving (A,C)
- Navigation — Return Data and Events to the Caller
- Navigation — Uncaught Error and Error Popup
On this page