Skip to content

Commit bc30125

Browse files
authored
update
1 parent 24f4231 commit bc30125

File tree

1 file changed

+146
-9
lines changed

1 file changed

+146
-9
lines changed

docs/development/events.md

Lines changed: 146 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,160 @@ outline: [2, 4]
33
---
44
# Events
55

6-
### Backend
6+
### Frontend
77

8-
`client->_event( t_arg = value # ( ( ...`
8+
#### Basic
99

10-
Check the documentation [here.](https://openui5.hana.ondemand.com/#/topic/b0fb4de7364f4bcbb053a99aa645affe) There are different ways for adressing the event handler ($event, $source, $params) and you can select your value for example with /mProperties/property.<br>
11-
<img width="500" alt="image" src="https://github.com/abap2UI5/abap2UI5-documentation/assets/102328295/6de59970-f766-46fd-a35a-933d26287564">
12-
<br>
13-
You can also call functions directly in the view as explained [here.](https://sapui5.hana.ondemand.com/#/entity/sap.m.ActionSheet/sample/sap.m.sample.ActionSheet/code/view/ActionSheet.fragment.xml) <br>
14-
<img width="500" alt="image" src="https://github.com/abap2UI5/abap2UI5-documentation/assets/102328295/17650cca-d84a-4e88-be2b-244ead773b52">
15-
<br>
10+
If an UI5 property is an event, just import the result of the method `client->_event` to trigger events in the backend. Check out the event with the value `client->get( )-event`:
1611

12+
```abap
13+
METHOD z2ui5_if_app~main.
14+
15+
client->view_display( z2ui5_cl_xml_view=>factory(
16+
)->button( text = 'post' press = client->_event( 'BUTTON_POST' )
17+
)->stringify( ) ).
18+
19+
CASE client->get( )-event.
1720
21+
WHEN 'BUTTON_POST'.
22+
client->message_box_display( |Your name is { name }| ).
1823
19-
#### Frontend
24+
WHEN OTHERS.
25+
ENDCASE.
26+
27+
ENDMETHOD.
28+
```
2029

30+
Sometimes the backend needs more information about the süpecific event, you can use the parameter `$event`, `$source` and `$params` to send further information into the backend. Therefore use the parameter `t_arg`. Check the documentation [here.](https://openui5.hana.ondemand.com/#/topic/b0fb4de7364f4bcbb053a99aa645affe). Check out sampple `Z2UI5_CL_DEMO_APP_167`:
2131

32+
#### Source Properties
33+
Send properties of the event source control:
34+
```abap
35+
METHOD z2ui5_if_app~main.
36+
37+
client->view_display( z2ui5_cl_xml_view=>factory(
38+
)->button( text = `post` press = client->_event( val = `BUTTON_POST`
39+
t_arg = VALUE #( ( `${$source>/text}` ) ) )
40+
)->stringify( ) ).
41+
42+
CASE client->get( )-event.
43+
44+
WHEN 'BUTTON_POST'.
45+
client->message_box_display( |The button text is { client->get_event_arg( 1 ) }| ).
46+
47+
WHEN OTHERS.
48+
ENDCASE.
49+
50+
ENDMETHOD.
51+
```
52+
53+
#### Event Parameters
54+
Read Event Parameters:
55+
```abap
56+
METHOD z2ui5_if_app~main.
57+
58+
client->view_display( z2ui5_cl_xml_view=>factory(
59+
)->button( text = `post` press = client->_event( val = `BUTTON_POST`
60+
t_arg = VALUE #( ( `${$source>/text}` ) ) )
61+
)->stringify( ) ).
62+
63+
CASE client->get( )-event.
64+
65+
WHEN 'BUTTON_POST'.
66+
client->message_box_display( |The button text is { client->get_event_arg( 1 ) }| ).
67+
68+
WHEN OTHERS.
69+
ENDCASE.
70+
71+
ENDMETHOD.
72+
```
73+
74+
#### Event Properties
75+
Read Event Parameters:
76+
```abap
77+
METHOD z2ui5_if_app~main.
78+
79+
client->view_display( z2ui5_cl_xml_view=>factory(
80+
)->button( text = `post` press = client->_event( val = `BUTTON_POST`
81+
t_arg = VALUE #( ( `${$source>/text}` ) ) )
82+
)->stringify( ) ).
83+
84+
CASE client->get( )-event.
85+
86+
WHEN 'BUTTON_POST'.
87+
client->message_box_display( |The button text is { client->get_event_arg( 1 ) }| ).
88+
89+
WHEN OTHERS.
90+
ENDCASE.
91+
92+
ENDMETHOD.
93+
```
94+
95+
#### Model Properties
96+
Read Event Parameters:
97+
```abap
98+
METHOD z2ui5_if_app~main.
99+
100+
client->view_display( z2ui5_cl_xml_view=>factory(
101+
)->button( text = `post` press = client->_event(
102+
val = `BUTTON_POST`
103+
t_arg = VALUE #( ( `${$source>/text}` ) ) )
104+
)->stringify( ) ).
105+
106+
CASE client->get( )-event.
107+
108+
WHEN 'BUTTON_POST'.
109+
client->message_box_display( |The button text is { client->get_event_arg( 1 ) }| ).
110+
111+
WHEN OTHERS.
112+
ENDCASE.
113+
114+
ENDMETHOD.
115+
```
116+
117+
### Frontend
118+
119+
#### Event Frontend
120+
121+
The following frontend events re availibkle:
122+
```abap
123+
CONSTANTS:
124+
BEGIN OF cs_event,
125+
popup_close TYPE string VALUE `POPUP_CLOSE`,
126+
open_new_tab TYPE string VALUE `OPEN_NEW_TAB`,
127+
popover_close TYPE string VALUE `POPOVER_CLOSE`,
128+
location_reload TYPE string VALUE `LOCATION_RELOAD`,
129+
nav_container_to TYPE string VALUE `NAV_CONTAINER_TO`,
130+
nest_nav_container_to TYPE string VALUE `NEST_NAV_CONTAINER_TO`,
131+
nest2_nav_container_to TYPE string VALUE `NEST2_NAV_CONTAINER_TO`,
132+
cross_app_nav_to_ext TYPE string VALUE `CROSS_APP_NAV_TO_EXT`,
133+
cross_app_nav_to_prev_app TYPE string VALUE `CROSS_APP_NAV_TO_PREV_APP`,
134+
popup_nav_container_to TYPE string VALUE `POPUP_NAV_CONTAINER_TO`,
135+
download_b64_file TYPE string VALUE `DOWNLOAD_B64_FILE`,
136+
set_size_limit TYPE string VALUE `SET_SIZE_LIMIT`,
137+
END OF cs_event.
138+
```
139+
140+
```abap
141+
METHOD z2ui5_if_app~main.
142+
143+
client->view_display( z2ui5_cl_xml_view=>factory(
144+
)->button( text = `post` press = client->_event( client->_event_client(
145+
val = client->cs_event-open_new_tab
146+
t_arg = VALUE #( ( `https://github.com/abap2UI5` ) ) ) )
147+
)->stringify( ) ).
148+
149+
ENDMETHOD.
150+
```
22151

23152
#### Follow Up Action
153+
```abap
154+
METHOD z2ui5_if_app~main.
24155
156+
client->follow_up_action( client->_event_client(
157+
val = client->cs_event-open_new_tab
158+
t_arg = VALUE #( ( `https://github.com/abap2UI5` ) ) ) ).
25159
160+
ENDMETHOD.
161+
```
162+
Check out sample `Z2UI5_CL_DEMO_APP_180` for a working snippet.

0 commit comments

Comments
 (0)