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
abap2UI5 gives you great flexibility in how you structure apps. Most sample apps follow the pattern below. Use it as a starting point, and tweak it or build a wrapper around abap2UI5 for more specific behavior.
7
+
8
+
The idea: every request enters the `main` method, and you use `CASE` to dispatch between initialization, navigation returns, and user events.
9
+
10
+
The following sections walk through each phase:
11
+
12
+
-[Life Cycle](/development/controller/life_cycle) — the overall dispatch pattern in `main`
13
+
-[Init](/development/controller/init) — first-time setup and rendering the view
14
+
-[Event](/development/controller/event) — handling user actions
15
+
-[Navigated](/development/controller/navigated) — returning from another app
`client->check_on_event` returns `abap_true` when the request was triggered by a user event. Read the event name with `client->get( )-event` and dispatch to the matching handler.
7
+
8
+
```abap
9
+
METHOD z2ui5_if_app~main.
10
+
11
+
me->client = client.
12
+
CASE abap_true.
13
+
WHEN client->check_on_event( ).
14
+
on_event( ).
15
+
ENDCASE.
16
+
17
+
ENDMETHOD.
18
+
19
+
METHOD on_event.
20
+
21
+
DATA(lt_arg) = client->get_event_arg( ).
22
+
23
+
CASE client->get( )-event.
24
+
WHEN `BUTTON_POST`.
25
+
client->message_toast_display( |{ mv_value } - send to the server| ).
Every request to an abap2UI5 app enters the `main` method. The recommended pattern uses `CASE abap_true` together with `client->check_on_init`, `client->check_on_event`, and `client->check_on_navigated` to dispatch to the matching handler method.
7
+
8
+
```abap
9
+
CLASS z2ui5_cl_demo_app_001 DEFINITION PUBLIC.
10
+
11
+
PUBLIC SECTION.
12
+
13
+
INTERFACES z2ui5_if_app.
14
+
15
+
DATA mv_value TYPE string.
16
+
17
+
PROTECTED SECTION.
18
+
19
+
DATA client TYPE REF TO z2ui5_if_client.
20
+
21
+
METHODS on_init.
22
+
METHODS display_view.
23
+
METHODS on_event.
24
+
METHODS on_navigated.
25
+
26
+
PRIVATE SECTION.
27
+
ENDCLASS.
28
+
29
+
CLASS z2ui5_cl_demo_app_001 IMPLEMENTATION.
30
+
31
+
METHOD z2ui5_if_app~main.
32
+
33
+
me->client = client.
34
+
CASE abap_true.
35
+
WHEN client->check_on_init( ).
36
+
on_init( ).
37
+
display_view( ).
38
+
WHEN client->check_on_event( ).
39
+
on_event( ).
40
+
WHEN client->check_on_navigated( ).
41
+
on_navigated( ).
42
+
ENDCASE.
43
+
44
+
ENDMETHOD.
45
+
46
+
ENDCLASS.
47
+
```
48
+
49
+
See the dedicated sections of this development guide for full details on views, events, data binding, and navigation.
`client->check_on_navigated` returns `abap_true` when the user returns from another app. Use `client->get_app_prev` to access the previous app instance and read any data it returns.
Copy file name to clipboardExpand all lines: docs/get_started/next.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ outline: [2, 4]
6
6
With abap2UI5 up and running, here are a few directions to take.
7
7
8
8
#### Development
9
-
Learn how to build views, handle events, share data, and work with tables. The development guide covers what you need for everyday work. Start with the [Development guide](/development/general).
9
+
Learn how to build views, handle events, share data, and work with tables. The development guide covers what you need for everyday work. Start with the [Development guide](/development/controller/controller).
10
10
11
11
#### Configuration
12
12
Getting ready for production? The configuration guides walk through security, performance tuning, Launchpad integration, and more. Start with the [Configuration guide](/configuration/setup).
0 commit comments