Navigation
Calling another app and coming back: nav_app_call puts the caller on a stack, nav_app_leave returns to it.
Z2UI5_CL_SMP_APP_024
Learn
Navigation
UI5 1.71
The facts
- Repository
- abap2UI5/samples
- Class
Z2UI5_CL_SMP_APP_024- Source file
z2ui5_cl_smp_app_024.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
- Documentation
- abap2ui5.github.io/docs/cookbook/event_navigation/navigatio… ↗
Keywords: nav_app_call, nav_app_leave, sub, app, stack, call, back
Controls it builds
- sap.m.Button
- sap.m.Input
- sap.m.Label
- sap.m.MessageStrip
- sap.m.Page
- sap.m.Shell
- sap.ui.core.mvc.View
- sap.ui.layout.Grid
- 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_smp_app_024.clas.abap — 140 lines
Click a number to link to a line — shift-click for a range.
Read it on GitHub ↗
" @keywords nav_app_call nav_app_leave sub app stack call back
" @summary Calling another app and coming back: nav_app_call puts the caller on a stack, nav_app_leave returns to it.
" @docs https://abap2ui5.github.io/docs/cookbook/event_navigation/navigation/inner_app
CLASS z2ui5_cl_smp_app_024 DEFINITION PUBLIC.
PUBLIC SECTION.
INTERFACES z2ui5_if_app.
DATA input TYPE string.
DATA input2 TYPE string.
DATA backend_event TYPE string.
PROTECTED SECTION.
DATA client TYPE REF TO z2ui5_if_client.
METHODS on_event.
METHODS view_display.
PRIVATE SECTION.
ENDCLASS.
CLASS z2ui5_cl_smp_app_024 IMPLEMENTATION.
METHOD z2ui5_if_app~main.
me->client = client.
IF client->check_on_init( ).
view_display( ).
ELSEIF client->check_on_navigated( ).
IF backend_event = `CALL_PREVIOUS_APP_INPUT_RETURN`.
DATA(app_025) = CAST z2ui5_cl_smp_app_025( client->get_app_prev( ) ).
backend_event = VALUE #( ).
client->message_box_display( |Input made in the previous app: { app_025->input }| ).
ENDIF.
view_display( ).
ELSEIF client->check_on_event( ).
on_event( ).
ENDIF.
ENDMETHOD.
METHOD on_event.
CASE client->get_event( ).
WHEN `CALL_NEW_APP`.
client->nav_app_call( NEW z2ui5_cl_smp_app_025( ) ).
WHEN `CALL_NEW_APP_VIEW`.
DATA(app) = NEW z2ui5_cl_smp_app_025( ).
app->show_view = `SECOND`.
client->nav_app_call( app ).
WHEN `CALL_NEW_APP_READ`.
DATA(app_next) = NEW z2ui5_cl_smp_app_025( ).
app_next->input_previous_set = input.
client->nav_app_call( app_next ).
WHEN `CALL_NEW_APP_EVENT`.
app_next = NEW z2ui5_cl_smp_app_025( ).
app_next->event_backend = `NEW_APP_EVENT`.
client->nav_app_call( app_next ).
ENDCASE.
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`
)->a( n = `xmlns:core` v = `sap.ui.core`
)->a( n = `xmlns:form` v = `sap.ui.layout.form`
)->a( n = `xmlns:layout` v = `sap.ui.layout` ).
DATA(page) = view->ele( `Shell`
)->ele( `Page`
)->a( n = `title` v = `abap2UI5 - Navigation - Call and Leave Apps (nav_app_call)`
)->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 = `App-to-app navigation: calls a second app in different ways - open a view, raise ` &&
`an event or pass data - and reads the input it returns.`
)->a( n = `type` v = `Information`
)->a( n = `showIcon` b = abap_true
)->a( n = `class` v = `sapUiSmallMargin` ).
page->ele( n = `Grid` ns = `layout`
)->a( n = `defaultSpan` v = `L6 M12 S12`
)->ele( n = `content` ns = `layout`
)->ele( n = `SimpleForm` ns = `form`
)->a( n = `title` v = `Controller`
)->a( n = `editable` b = abap_true
)->ele( n = `content` ns = `form`
)->tag( `Label`
)->a( n = `text` v = `Demo`
)->tag( `Button`
)->a( n = `press` v = client->_event( `CALL_NEW_APP` )
)->a( n = `text` v = `call new app (first View)`
)->tag( `Label`
)->a( n = `text` v = `Demo`
)->tag( `Button`
)->a( n = `press` v = client->_event( `CALL_NEW_APP_VIEW` )
)->a( n = `text` v = `call new app (second View)`
)->tag( `Label`
)->a( n = `text` v = `Demo`
)->tag( `Button`
)->a( n = `press` v = client->_event( `CALL_NEW_APP_EVENT` )
)->a( n = `text` v = `call new app (set Event)`
)->tag( `Label`
)->a( n = `text` v = `Demo`
)->tag( `Input`
)->a( n = `value` v = client->_bind( input )
)->tag( `Button`
)->a( n = `press` v = client->_event( `CALL_NEW_APP_READ` )
)->a( n = `text` v = `call new app (set data)`
)->tag( `Label`
)->a( n = `text` v = `some data, you can read in the next app`
)->tag( `Input`
)->a( n = `value` v = client->_bind( input2 ) ).
client->view_display( view->stringify( ) ).
ENDMETHOD.
ENDCLASS.
More in Navigation
- 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