You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: clarify view rebuild on navigation return vs check_on_init
Add a lifecycle pitfall explaining that returning from a sub-app or popup
triggers check_on_navigated, not check_on_init, so apps that render only
under check_on_init show a blank screen on return.
Copy file name to clipboardExpand all lines: docs/cookbook/event_navigation/life_cycle.md
+29Lines changed: 29 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,6 +62,35 @@ abap2UI5 does not re-render the view automatically. After an event, if you do **
62
62
63
63
Call `view_display( )` again only when the **structure** of the view needs to change: different controls, different bindings, a new dialog, navigation to a different screen. Rebuilding and re-sending the view on every event is wasteful and can cause visible flicker, lost scroll position, and lost focus.
64
64
65
+
### Returning From a Sub-App Hits `check_on_navigated`, Not `check_on_init`
66
+
`check_on_init( )` is `abap_true`**exactly once** — on the very first call of an app instance. It does *not* fire again when control comes back to the app after a `nav_app_call( )` (a popup or a fullscreen sub-app) is closed with `nav_app_leave( )`. That return is signalled by `check_on_navigated( )`.
67
+
68
+
This trips up apps that build their view only under `check_on_init`:
69
+
70
+
```abap
71
+
" WRONG — screen is blank after returning from the sub-app
72
+
CASE abap_true.
73
+
WHEN client->check_on_init( ).
74
+
render_main( ). " runs only the first time
75
+
WHEN client->check_on_event( `OPEN_POPUP` ).
76
+
client->nav_app_call( ... ).
77
+
ENDCASE.
78
+
```
79
+
80
+
When the sub-app is left, `main` runs again, but neither `check_on_init` nor any event matches, so `view_display( )` is never called and the user is left looking at a stale or empty screen. Render from the navigation-return branch as well — `check_on_navigated( )` fires both on the first display *and* on every return, so reacting to it alone is usually enough:
81
+
82
+
```abap
83
+
" CORRECT — the view is rebuilt on first display and on every return
84
+
CASE abap_true.
85
+
WHEN client->check_on_navigated( ).
86
+
render_main( ).
87
+
WHEN client->check_on_event( `OPEN_POPUP` ).
88
+
client->nav_app_call( ... ).
89
+
ENDCASE.
90
+
```
91
+
92
+
Reserve `check_on_init` for one-time setup that must *not* repeat on return (loading initial data, setting defaults). As a rule of thumb: anything needed to **show the screen** belongs in a branch that also fires on navigation return.
93
+
65
94
### `check_on_event` Fires Once Per Roundtrip
66
95
Every HTTP request carries at most one event. `check_on_event( )` returns `abap_true` exactly once per call to `main`, for that single event. If the user clicks two buttons in quick succession, the framework dispatches them as two independent `main` invocations — they are never batched into one request.
0 commit comments