Skip to content

Commit 941d7f0

Browse files
committed
docs: sync frontend/binding docs with the unified root model and view parameter
- nested_views: the per-view model separation is gone (all _bind data goes to one root model) and _bind's view parameter is now an inert no-op; rewrite the routing section to choose the target view via the matching ..._view_model_update() call and drop the no-op view= from the examples - frontend: refresh the stale cs_event listing and document the whitelisted control_by_id/control_global/binding_call calls plus the new view importing parameter on _event_client - follow_up_action: document the whitelisted control calls and the view parameter - xml_templating: drop a leftover duplicate _bind reference from the _bind_edit sweep Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NjYGeMm8yvpJhavp6hdGyN
1 parent adecee6 commit 941d7f0

4 files changed

Lines changed: 102 additions & 29 deletions

File tree

docs/cookbook/event_navigation/frontend.md

Lines changed: 61 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,39 @@ The following frontend events are available:
1414
```abap
1515
CONSTANTS:
1616
BEGIN OF cs_event,
17+
18+
"Framework
1719
popup_close TYPE string VALUE `POPUP_CLOSE`,
18-
open_new_tab TYPE string VALUE `OPEN_NEW_TAB`,
1920
popover_close TYPE string VALUE `POPOVER_CLOSE`,
20-
location_reload TYPE string VALUE `LOCATION_RELOAD`,
21-
nav_container_to TYPE string VALUE `NAV_CONTAINER_TO`,
22-
nest_nav_container_to TYPE string VALUE `NEST_NAV_CONTAINER_TO`,
23-
nest2_nav_container_to TYPE string VALUE `NEST2_NAV_CONTAINER_TO`,
21+
set_size_limit TYPE string VALUE `SET_SIZE_LIMIT`,
22+
set_odata_model TYPE string VALUE `SET_ODATA_MODEL`,
2423
cross_app_nav_to_ext TYPE string VALUE `CROSS_APP_NAV_TO_EXT`,
2524
cross_app_nav_to_prev_app TYPE string VALUE `CROSS_APP_NAV_TO_PREV_APP`,
26-
popup_nav_container_to TYPE string VALUE `POPUP_NAV_CONTAINER_TO`,
27-
download_b64_file TYPE string VALUE `DOWNLOAD_B64_FILE`,
28-
set_size_limit TYPE string VALUE `SET_SIZE_LIMIT`,
25+
26+
"Actions
27+
clipboard_copy TYPE string VALUE `CLIPBOARD_COPY`,
28+
clipboard_app_state TYPE string VALUE `CLIPBOARD_APP_STATE`,
2929
set_title TYPE string VALUE `SET_TITLE`,
3030
set_title_launchpad TYPE string VALUE `SET_TITLE_LAUNCHPAD`,
3131
set_focus TYPE string VALUE `SET_FOCUS`,
3232
scroll_to TYPE string VALUE `SCROLL_TO`,
3333
scroll_into_view TYPE string VALUE `SCROLL_INTO_VIEW`,
3434
start_timer TYPE string VALUE `START_TIMER`,
3535
keyboard_set_mode TYPE string VALUE `KEYBOARD_SET_MODE`,
36-
clipboard_copy TYPE string VALUE `CLIPBOARD_COPY`,
37-
clipboard_app_state TYPE string VALUE `CLIPBOARD_APP_STATE`,
36+
open_new_tab TYPE string VALUE `OPEN_NEW_TAB`,
37+
location_reload TYPE string VALUE `LOCATION_RELOAD`,
38+
system_logout TYPE string VALUE `SYSTEM_LOGOUT`,
39+
download_b64_file TYPE string VALUE `DOWNLOAD_B64_FILE`,
40+
urlhelper TYPE string VALUE `URLHELPER`,
3841
history_back TYPE string VALUE `HISTORY_BACK`,
42+
store_data TYPE string VALUE `STORE_DATA`,
43+
play_audio TYPE string VALUE `PLAY_AUDIO`,
44+
45+
"Control calls (whitelisted, positional t_arg)
46+
control_by_id TYPE string VALUE `CONTROL_BY_ID`,
47+
control_global TYPE string VALUE `CONTROL_GLOBAL`,
48+
binding_call TYPE string VALUE `BINDING_CALL`,
49+
3950
END OF cs_event.
4051
```
4152
For example, to open a new tab directly from a button press (no backend involved):
@@ -52,3 +63,43 @@ METHOD z2ui5_if_app~main.
5263
5364
ENDMETHOD.
5465
```
66+
67+
## Calling control methods on the frontend
68+
69+
The last three constants — `control_by_id`, `control_global` and `binding_call` — are frontend events too, but instead of a fixed built-in action they invoke a *whitelisted* method on a control, a global object or a binding. Their arguments are **positional**: an empty argument between two filled ones keeps its slot as `` `` ``.
70+
71+
| Event | `t_arg` (positional) |
72+
| ---------------- | ------------------------------------------------------------------------------------ |
73+
| `control_by_id` | `id`, `method`, `params…` — call a whitelisted method on a control resolved by id |
74+
| `control_global` | `object`, `method`, `params…``MESSAGE_TOAST`, `MESSAGE_BOX`, `BUSY_INDICATOR`, `THEMING` |
75+
| `binding_call` | `path`, `method`, `params…` — e.g. `filter` (operator, value1, value2) or `sort` (path, descending, group) |
76+
77+
```abap
78+
" toggle a MessagePopover open, anchored to the pressing button, no roundtrip
79+
press = client->_event_client(
80+
val = client->cs_event-control_by_id
81+
t_arg = VALUE #( ( `msgPopover` ) ( `toggleBy` ) ( `${$source>/id}` ) ) )
82+
```
83+
84+
The same events also work from the backend with `client->follow_up_action( )` using the identical `t_arg`.
85+
86+
### The `view` parameter
87+
88+
For `control_by_id`, the control is looked up by id. Both `_event_client( )` and `follow_up_action( )` take a separate `view` parameter (default `cs_view-main`) that scopes this lookup:
89+
90+
- omit it (or pass `cs_view-main`) — the id is resolved across all open views;
91+
- pass `cs_view-popup` / `cs_view-popover` / `cs_view-nested` / … — the lookup is scoped to a control hosted in that view (e.g. a control living inside a popup).
92+
93+
```abap
94+
" call a method on a control that lives inside the popup view
95+
press = client->_event_client(
96+
val = client->cs_event-control_by_id
97+
view = client->cs_view-popup
98+
t_arg = VALUE #( ( `NavCon` ) ( `to` ) ( `${$parameters>/selectedKey}` ) ) )
99+
```
100+
101+
::: tip Migrated from a positional view slot
102+
The view used to be the second entry of `t_arg` (`id`, `view`, `method`, …). It is now the dedicated `view` importing parameter, so main-view calls simply omit it. Older examples that still pass `` `MAIN` `` as the second `t_arg` element continue to work.
103+
:::
104+
105+
`control_global` and `binding_call` are not resolved by id and ignore `view`.

docs/cookbook/expert_more/follow_up_action.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,30 @@ client->follow_up_action( `myFunction()` ).
5353
plain event name (only `A-Z`, `a-z`, `0-9`, `_`) becomes a frontend event call,
5454
anything containing JavaScript syntax runs verbatim.
5555

56+
## Calling a control method
57+
58+
The whitelisted control calls — `cs_event-control_by_id`, `control_global` and
59+
`binding_call` — are frontend events too, so `follow_up_action( )` can invoke a
60+
method on a control once the backend response arrives. Their `t_arg` is
61+
positional (see [Frontend → Calling control methods](/cookbook/event_navigation/frontend#calling-control-methods-on-the-frontend)):
62+
63+
```abap
64+
" after backend processing, advance a wizard step
65+
client->follow_up_action(
66+
val = client->cs_event-control_by_id
67+
t_arg = VALUE #( ( `wiz` ) ( `setNextStep` ) ( `STEP2` ) ) ).
68+
```
69+
70+
For `control_by_id`, the control is resolved by id. A separate `view` parameter
71+
(default `cs_view-main`, which resolves the id across all open views) scopes the
72+
lookup to a single view — pass `cs_view-popup` / `cs_view-popover` / … for a
73+
control hosted in a popup or popover:
74+
75+
```abap
76+
client->follow_up_action(
77+
val = client->cs_event-control_by_id
78+
view = client->cs_view-popup
79+
t_arg = VALUE #( ( `NavCon` ) ( `to` ) ( `detail` ) ) ).
80+
```
81+
5682
See sample `Z2UI5_CL_DEMO_APP_180` for a complete example.

docs/cookbook/view/nested_views.md

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ DATA(lr_master) = page->flexible_column_layout(
103103
id = `test` " anchor
104104
)->begin_column_pages( ).
105105
106-
lr_master->list( items = client->_bind( val = t_tab
107-
view = client->cs_view-main )
106+
lr_master->list( items = client->_bind( t_tab )
108107
selectionchange = client->_event( `SELCHANGE` )
109108
)->standard_list_item( title = `{TITLE}`
110109
selected = `{SELECTED}` ).
@@ -119,8 +118,7 @@ METHOD view_display_detail.
119118
DATA(lo_view_nested) = z2ui5_cl_xml_view=>factory( ).
120119
DATA(page) = lo_view_nested->page( `Nested View` ).
121120
122-
page->ui_table( rows = client->_bind( val = t_tab2
123-
view = client->cs_view-nested ) ).
121+
page->ui_table( rows = client->_bind( t_tab2 ) ).
124122
" ...columns, toolbar, row actions...
125123
126124
client->nest_view_display(
@@ -139,26 +137,24 @@ End-to-end samples:
139137
- `Z2UI5_CL_DEMO_APP_097` — list master, `sap.ui.table.Table` in the detail with sort/filter/row actions.
140138
- `Z2UI5_CL_DEMO_APP_085` — full master-detail with an `ObjectPageLayout` as the nested detail, including search, sort, and the FCL fullscreen toggle.
141139

142-
#### Routing Bindings to the Right View
140+
#### Refreshing the Right View
143141

144-
Each view (main, nested) has its own client-side model. When you build a binding with `client->_bind( ... )` you can declare which view's model the binding belongs to via the `view` parameter:
145-
146-
```abap
147-
" In the main view
148-
items = client->_bind( val = t_tab view = client->cs_view-main )
149-
150-
" In the nested view
151-
rows = client->_bind( val = t_tab2 view = client->cs_view-nested )
152-
```
153-
154-
The constants `client->cs_view-main` and `client->cs_view-nested` are abap2UI5's view identifiers. Declaring them lets `nest_view_model_update( )` know which model to refresh:
142+
All bound data lives in a **single client-side model**, regardless of which view a binding was built in — `client->_bind( ... )` always writes to that one root model. What differs is *which rendered view you refresh* after the ABAP data changes: call the update method that matches the view.
155143

156144
```abap
157145
DELETE t_tab2 WHERE title = ls_arg-title.
158-
client->nest_view_model_update( ). " only the nested view's data is pushed
146+
client->nest_view_model_update( ). " push the new data into the nested view
159147
```
160148

161-
If you omit `view`, the binding defaults to the main view, which still works for many cases but is less explicit. Get into the habit of passing the right `cs_view-...` value whenever a fragment is built — it makes the data flow obvious to anyone reading the code.
149+
| Rendered view | Refresh call |
150+
| ------------- | ------------------------------------- |
151+
| main | `client->view_model_update( )` |
152+
| nested | `client->nest_view_model_update( )` |
153+
| nested (2nd) | `client->nest2_view_model_update( )` |
154+
155+
::: tip `_bind`'s `view` parameter is obsolete
156+
Earlier releases kept a separate model per view and asked you to tag each binding with `view = client->cs_view-...` so the framework knew which model to refresh. That separation is gone — there is now one root model — and the `view` parameter of `_bind` / `_bind_edit` is an inert no-op kept only for backward compatibility. Omit it, and pick the target view through the matching `..._view_model_update( )` call instead.
157+
:::
162158

163159
#### Two Levels of Nesting
164160

docs/cookbook/view/xml_templating.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ This timing has two consequences:
1919
- **Expansion is build-time.** A `template:repeat` over an internal table produces a fixed number of controls; the expanded XML is what UI5 renders.
2020
- **Data changes do not re-template.** If the data driving the template changes, the existing expansion stays as is. To pick up the change you must rebuild the view (`view_display`) or the templated fragment (`nest_view_display`) — see [Re-rendering](#re-rendering) below.
2121

22-
abap2UI5 wires up the templating model for you. Every variable you bind with `client->_bind( ... )` or `client->_bind( ... )` is reachable inside templates via the `template>` model prefix:
22+
abap2UI5 wires up the templating model for you. Every variable you bind with `client->_bind( ... )` is reachable inside templates via the `template>` model prefix:
2323

2424
| ABAP binding | Path inside templates |
2525
| ---------------------------------- | --------------------------- |

0 commit comments

Comments
 (0)