Skip to content

Commit cb05d56

Browse files
authored
Merge pull request #122 from abap2UI5/claude/view-init-navigation-3nfffr
Clarify view re-display behavior on app navigation return
2 parents fe8b7c6 + 966c180 commit cb05d56

3 files changed

Lines changed: 36 additions & 5 deletions

File tree

docs/advanced/agent.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,18 @@ ENDCLASS.
5555
IF client->check_on_init( ). " first call
5656
" load data + render view
5757
ELSEIF client->check_on_navigated( ). " returned from a called sub-app (nav_app_call), incl. built-in popup apps
58-
" refresh state
58+
" re-display the view - the sub-app's view is still on screen; state survived serialization, no data re-read needed
5959
ELSEIF client->check_on_event( `POST` ). " user fired event 'POST'
6060
" handle it
6161
ENDIF.
6262
```
6363

6464
[Life Cycle](/cookbook/event_navigation/life_cycle)
6565

66+
::: 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+
6670
#### 3. State lives in **public** class attributes
6771

6872
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
121125

122126
## Canonical App Template
123127

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.
125129

126130
```abap
127131
CLASS zcl_app_xxx DEFINITION PUBLIC.
@@ -135,7 +139,6 @@ CLASS zcl_app_xxx DEFINITION PUBLIC.
135139
136140
METHODS on_init. " first call: load data, render view
137141
METHODS on_event. " user triggered an event
138-
METHODS on_navigation. " returned from a sub-app called via nav_app_call
139142
METHODS view_display. " build and render the view
140143
METHODS data_read. " SELECT
141144
METHODS data_update. " INSERT / UPDATE / DELETE
@@ -153,7 +156,7 @@ CLASS zcl_app_xxx IMPLEMENTATION.
153156
IF client->check_on_init( ).
154157
on_init( ).
155158
ELSEIF client->check_on_navigated( ).
156-
on_navigation( ).
159+
view_display( ).
157160
ELSEIF client->check_on_event( ).
158161
on_event( ).
159162
ENDIF.
@@ -251,7 +254,7 @@ When an AI needs deeper information than this page provides:
251254

252255
A prompt that gives an AI assistant enough context to produce a working app:
253256

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.
255258
256259
## Hard Rules (Cheat Sheet)
257260

@@ -260,6 +263,7 @@ A prompt that gives an AI assistant enough context to produce a working app:
260263
| Implement `z2ui5_if_app` with a single `main` method | The only entry point the framework calls |
261264
| Bound attributes must be `PUBLIC` | The framework binds via dynamic ASSIGN; `PROTECTED`/`PRIVATE` are silently ignored |
262265
| 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 |
263267
| Use `z2ui5_cl_util_xml` for AI-generated views | Maps 1:1 to UI5 SDK; no wrapper to learn |
264268
| Pass XML boolean attributes as string literals `'true'` / `'false'` | `abap_true` / `abap_false` produce invalid or empty attributes |
265269
| Use backtick string literals (`` ` ``), not single quotes | Project-wide convention enforced by abaplint |

docs/cookbook/event_navigation/navigation.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,14 @@ To read data from the previous app, cast it like this:
3232
IF client->check_on_navigated( ).
3333
DATA(lo_called_app) = CAST z2ui5_cl_new_app( client->get_app_prev( ) ).
3434
client->message_box_display( `Input made in the previous app:` && lo_called_app->mv_input ).
35+
view_display( ).
3536
ENDIF.
3637
3738
ENDMETHOD.
3839
```
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+
:::
3943
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:
4044
```abap
4145
METHOD z2ui5_if_app~main.

docs/public/llms.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# abap2UI5
2+
3+
> 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

Comments
 (0)