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
::: warning The #1 lifecycle bug: blank screen after navigation
67
+
Always call `view_display( )` in the `check_on_navigated( )` branch. When a called sub-app took over the screen and returns via `nav_app_leave( )`, the browser still shows the sub-app's view — the framework does not restore the previous view automatically. All class attributes survived the roundtrip serialization, so no data re-read is needed — just render the view again. Skipping this leaves the user on a blank or stale screen after navigating back.
68
+
:::
69
+
66
70
#### 3. State lives in **public** class attributes
67
71
68
72
Anything bound to the view must be `PUBLIC`. The framework serializes public attributes between roundtrips automatically — no session handling needed.
@@ -121,7 +125,7 @@ Complete worked example: see [Quickstart](/get_started/quickstart), [Hello World
121
125
122
126
## Canonical App Template
123
127
124
-
For anything beyond ~50 lines in `main`, extract `on_init` and `on_event` first, then add helpers (`view_display`, `data_read`, `data_update`) only when needed. Class names lowercase, no `FINAL`, definition order `TYPES` → `DATA` → `METHODS`.
128
+
For anything beyond ~50 lines in `main`, extract `on_init` and `on_event` first, then add helpers (`view_display`, `data_read`, `data_update`) only when needed. Class names lowercase, no `FINAL`, definition order `TYPES` → `DATA` → `METHODS`. In the `check_on_navigated( )` branch call `view_display( )` directly — the state survived serialization, only the view is gone from the browser.
125
129
126
130
```abap
127
131
CLASS zcl_app_xxx DEFINITION PUBLIC.
@@ -135,7 +139,6 @@ CLASS zcl_app_xxx DEFINITION PUBLIC.
135
139
136
140
METHODS on_init. " first call: load data, render view
137
141
METHODS on_event. " user triggered an event
138
-
METHODS on_navigation. " returned from a sub-app called via nav_app_call
139
142
METHODS view_display. " build and render the view
140
143
METHODS data_read. " SELECT
141
144
METHODS data_update. " INSERT / UPDATE / DELETE
@@ -153,7 +156,7 @@ CLASS zcl_app_xxx IMPLEMENTATION.
153
156
IF client->check_on_init( ).
154
157
on_init( ).
155
158
ELSEIF client->check_on_navigated( ).
156
-
on_navigation( ).
159
+
view_display( ).
157
160
ELSEIF client->check_on_event( ).
158
161
on_event( ).
159
162
ENDIF.
@@ -251,7 +254,7 @@ When an AI needs deeper information than this page provides:
251
254
252
255
A prompt that gives an AI assistant enough context to produce a working app:
253
256
254
-
> You are building an abap2UI5 app. Read <https://abap2ui5.github.io/docs/advanced/agent.html> first — it is the single source of truth for app-building (template, client API, lifecycle, view builder, deprecated controls, documentation map). For working examples, browse <https://github.com/abap2UI5/samples/tree/main/src> (250+ apps, one feature per app). Use `z2ui5_cl_util_xml` as the view builder. Look up any UI5 control at <https://ui5.sap.com/#/api> and translate the XML 1:1 to ABAP. Do not use any control listed in this page's "Deprecated UI5 Controls" section.
257
+
> You are building an abap2UI5 app. Read <https://abap2ui5.github.io/docs/advanced/agent.html> first — it is the single source of truth for app-building (template, client API, lifecycle, view builder, deprecated controls, documentation map). For working examples, browse <https://github.com/abap2UI5/samples/tree/main/src> (250+ apps, one feature per app). Use `z2ui5_cl_util_xml` as the view builder. Look up any UI5 control at <https://ui5.sap.com/#/api> and translate the XML 1:1 to ABAP. Do not use any control listed in this page's "Deprecated UI5 Controls" section. Always call `view_display( )` in the `check_on_navigated( )` branch — otherwise the screen is blank after returning from a called sub-app.
255
258
256
259
## Hard Rules (Cheat Sheet)
257
260
@@ -260,6 +263,7 @@ A prompt that gives an AI assistant enough context to produce a working app:
260
263
| Implement `z2ui5_if_app` with a single `main` method | The only entry point the framework calls |
261
264
| Bound attributes must be `PUBLIC`| The framework binds via dynamic ASSIGN; `PROTECTED`/`PRIVATE` are silently ignored |
262
265
| Use `IF` / `ELSEIF` with `check_on_init` / `check_on_event( 'NAME' )` / `check_on_navigated`| Canonical dispatcher pattern |
266
+
| Always call `view_display( )` in the `check_on_navigated` branch | The browser still shows the called sub-app's view after `nav_app_leave( )` — without a re-display the screen stays blank |
263
267
| Use `z2ui5_cl_util_xml` for AI-generated views | Maps 1:1 to UI5 SDK; no wrapper to learn |
264
268
| Pass XML boolean attributes as string literals `'true'` / `'false'`|`abap_true` / `abap_false` produce invalid or empty attributes |
265
269
| Use backtick string literals (`` ` ``), not single quotes | Project-wide convention enforced by abaplint |
client->message_box_display( `Input made in the previous app:` && lo_called_app->mv_input ).
35
+
view_display( ).
35
36
ENDIF.
36
37
37
38
ENDMETHOD.
38
39
```
40
+
::: warning Re-display your view on return
41
+
When the called app took over the screen with its own `view_display( )`, the browser still shows that view after `nav_app_leave( )` — the framework does not restore the previous view automatically. Call `view_display( )` again in the `check_on_navigated( )` branch. Your class attributes survived the roundtrip serialization, so no data re-read is needed — only the view must be rendered again. See [Life Cycle](/cookbook/event_navigation/life_cycle#returning-from-a-sub-app-hits-check_on_navigated-not-check_on_init).
42
+
:::
39
43
Called **with** an app instance, `nav_app_leave` works differently: it leaves the current app and starts the given one *without* pushing the current app onto the call stack — so there is nothing to return to. Use this to navigate forward while discarding the current app:
> abap2UI5 is an open-source framework for building SAP UI5 apps purely in ABAP — no JavaScript, OData or RAP required. An app implements the interface `z2ui5_if_app` with a single `main( )` method; the framework calls it on every HTTP roundtrip.
4
+
5
+
Key facts for AI assistants generating abap2UI5 apps:
6
+
7
+
- The canonical AI briefing is https://abap2ui5.github.io/docs/advanced/agent.html — read it before generating any app code.
8
+
- Dispatch inside `main( )` with `IF` / `ELSEIF` over `client->check_on_init( )`, `client->check_on_navigated( )` and `client->check_on_event( 'NAME' )`.
9
+
- CRITICAL — most common bug: always call `view_display( )` in the `check_on_navigated( )` branch. After returning from a sub-app called via `nav_app_call( )`, the browser still shows the sub-app's view — the framework does not restore the previous view automatically. App state survives the roundtrip serialization, so no data re-read is needed; only the view must be rendered again. Skipping this leaves a blank screen after navigating back.
10
+
- Build views as UI5 XML strings with `z2ui5_cl_util_xml` (1:1 translation of UI5 SDK XML, recommended for AI) or `z2ui5_cl_xml_view` (fluent API).
11
+
- Attributes bound with `_bind` / `_bind_edit` must be PUBLIC; use backtick string literals.
12
+
13
+
## Docs
14
+
15
+
- [AI Agent Briefing](https://abap2ui5.github.io/docs/advanced/agent.html): single source of truth for app-building (template, client API, lifecycle, view builders, deprecated controls)
16
+
- [Life Cycle](https://abap2ui5.github.io/docs/cookbook/event_navigation/life_cycle.html): lifecycle checks and pitfalls, including the blank-screen-after-navigation bug
17
+
- [Navigation](https://abap2ui5.github.io/docs/cookbook/event_navigation/navigation.html): cross-app navigation and re-displaying the view on return
18
+
- [Quickstart](https://abap2ui5.github.io/docs/get_started/quickstart.html): installation and first app
19
+
20
+
## Examples
21
+
22
+
- [Samples repository](https://github.com/abap2UI5/samples): 250+ working demo apps, one feature per app
23
+
- [Framework repository](https://github.com/abap2UI5/abap2UI5): core framework, architecture documented in AGENTS.md
0 commit comments