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
Copy file name to clipboardExpand all lines: docs/development/events/backend.md
+7-64Lines changed: 7 additions & 64 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,11 @@
1
1
---
2
2
outline: [2, 4]
3
3
---
4
-
# Events
4
+
# Backend
5
5
6
-
UI5 control properties can both display data and fire events. This section walks through backend events, frontend events, and follow-up actions.
6
+
UI5 control properties can both display data and fire events. To run backend logic when an event fires, use the `client->_event` method.
7
7
8
-
### Backend
9
-
To run backend logic when an event fires, use the `client->_event` method.
10
-
11
-
#### Basic
8
+
## Basic
12
9
As an example, we use the `press` property of a button. To fire events to the backend, assign the result of `client->_event( 'MY_EVENT_NAME' )` to the matching UI5 control property. The backend can then read the event details with `client->get( )-event`.
13
10
14
11
```abap
@@ -35,7 +32,7 @@ If the backend needs more details about the event, use the `t_arg` parameter to
35
32
36
33
For details, see the [UI5 docs on event handler arguments](https://openui5.hana.ondemand.com/#/topic/b0fb4de7364f4bcbb053a99aa645affe) and sample `Z2UI5_CL_DEMO_APP_167`.
37
34
38
-
####Source
35
+
## Source
39
36
Send properties of the event source control to the backend. The syntax `${$source>/text}` reads the `text` property of the UI5 control that fired the event — here, the button itself, returning the button's label (`post`):
40
37
41
38
```abap
@@ -56,7 +53,7 @@ METHOD z2ui5_if_app~main.
56
53
ENDMETHOD.
57
54
```
58
55
59
-
####Parameters
56
+
## Parameters
60
57
Read parameters of the event. The syntax `${$parameters>/id}` reads the `id` parameter out of the event's parameter map — UI5 builds a qualified ID like `mainView--button_id`:
61
58
```abap
62
59
METHOD z2ui5_if_app~main.
@@ -76,7 +73,7 @@ METHOD z2ui5_if_app~main.
76
73
ENDMETHOD.
77
74
```
78
75
79
-
####Event
76
+
## Event
80
77
Read specific properties of the event object. The syntax `$event>sId` reads the `sId` attribute of the UI5 event — here it returns the event type name (`press`). Note: there's no `${...}` wrapper because `$event` directly references the event object:
81
78
```abap
82
79
METHOD z2ui5_if_app~main.
@@ -99,7 +96,7 @@ ENDMETHOD.
99
96
You can read any object attribute, but use only public and released attributes to avoid compatibility issues with future UI5 versions.
100
97
:::
101
98
102
-
####Model Properties
99
+
## Model Properties
103
100
Read model properties bound to the event:
104
101
```abap
105
102
CLASS z2ui5_cl_app_hello_world DEFINITION PUBLIC.
@@ -133,57 +130,3 @@ ENDCLASS.
133
130
::: tip
134
131
This is just a demo. Reading `name` directly would be easier — the framework updates it automatically.
135
132
:::
136
-
137
-
### Frontend
138
-
If you don't want to handle the event in the backend, fire actions directly on the frontend with `client->_event_client`. The difference between the two methods:
139
-
140
-
-**`client->_event( )`** — causes a backend roundtrip; the event runs in the `main` method
141
-
-**`client->_event_client( )`** — runs an action directly in the browser; no backend call
142
-
143
-
To use a frontend event on a UI5 control property (like `press`), wrap `_event_client` inside `_event`. To fire a frontend event after backend processing, pass `_event_client` to `client->follow_up_action`.
144
-
145
-
The following frontend events are available:
146
-
```abap
147
-
CONSTANTS:
148
-
BEGIN OF cs_event,
149
-
popup_close TYPE string VALUE `POPUP_CLOSE`,
150
-
open_new_tab TYPE string VALUE `OPEN_NEW_TAB`,
151
-
popover_close TYPE string VALUE `POPOVER_CLOSE`,
152
-
location_reload TYPE string VALUE `LOCATION_RELOAD`,
153
-
nav_container_to TYPE string VALUE `NAV_CONTAINER_TO`,
154
-
nest_nav_container_to TYPE string VALUE `NEST_NAV_CONTAINER_TO`,
155
-
nest2_nav_container_to TYPE string VALUE `NEST2_NAV_CONTAINER_TO`,
156
-
cross_app_nav_to_ext TYPE string VALUE `CROSS_APP_NAV_TO_EXT`,
157
-
cross_app_nav_to_prev_app TYPE string VALUE `CROSS_APP_NAV_TO_PREV_APP`,
158
-
popup_nav_container_to TYPE string VALUE `POPUP_NAV_CONTAINER_TO`,
159
-
download_b64_file TYPE string VALUE `DOWNLOAD_B64_FILE`,
160
-
set_size_limit TYPE string VALUE `SET_SIZE_LIMIT`,
161
-
END OF cs_event.
162
-
```
163
-
For example, to open a new tab with the matching event:
164
-
```abap
165
-
METHOD z2ui5_if_app~main.
166
-
167
-
client->view_display( z2ui5_cl_xml_view=>factory(
168
-
)->button(
169
-
text = `post`
170
-
press = client->_event( client->_event_client(
171
-
val = client->cs_event-open_new_tab
172
-
t_arg = VALUE #( ( `https://github.com/abap2UI5` ) ) ) )
173
-
)->stringify( ) ).
174
-
175
-
ENDMETHOD.
176
-
```
177
-
178
-
### Follow-up Action
179
-
Sometimes you need to call a backend function and then act on the frontend right afterward. The follow-up action event covers this:
180
-
```abap
181
-
METHOD z2ui5_if_app~main.
182
-
183
-
client->follow_up_action( client->_event_client(
184
-
val = client->cs_event-open_new_tab
185
-
t_arg = VALUE #( ( `https://github.com/abap2UI5` ) ) ) ).
186
-
187
-
ENDMETHOD.
188
-
```
189
-
See sample `Z2UI5_CL_DEMO_APP_180` for a complete example.
If you don't want to handle the event in the backend, fire actions directly on the frontend with `client->_event_client`. The difference between the two methods:
7
+
8
+
-**`client->_event( )`** — causes a backend roundtrip; the event runs in the `main` method
9
+
-**`client->_event_client( )`** — runs an action directly in the browser; no backend call
10
+
11
+
To use a frontend event on a UI5 control property (like `press`), wrap `_event_client` inside `_event`. To fire a frontend event after backend processing, pass `_event_client` to `client->follow_up_action`.
12
+
13
+
The following frontend events are available:
14
+
```abap
15
+
CONSTANTS:
16
+
BEGIN OF cs_event,
17
+
popup_close TYPE string VALUE `POPUP_CLOSE`,
18
+
open_new_tab TYPE string VALUE `OPEN_NEW_TAB`,
19
+
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`,
24
+
cross_app_nav_to_ext TYPE string VALUE `CROSS_APP_NAV_TO_EXT`,
25
+
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`,
29
+
END OF cs_event.
30
+
```
31
+
For example, to open a new tab with the matching event:
32
+
```abap
33
+
METHOD z2ui5_if_app~main.
34
+
35
+
client->view_display( z2ui5_cl_xml_view=>factory(
36
+
)->button(
37
+
text = `post`
38
+
press = client->_event( client->_event_client(
39
+
val = client->cs_event-open_new_tab
40
+
t_arg = VALUE #( ( `https://github.com/abap2UI5` ) ) ) )
0 commit comments