Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions docs/cookbook/event_navigation/backend.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ METHOD z2ui5_if_app~main.

ENDMETHOD.
```
If the backend needs more details about the event, use the `t_arg` parameter to add extra info. Three prefixes are available:
If the backend needs more details about the event, use the `arg` parameter to add extra info. Three prefixes are available:

- **`$source`** — the UI5 control that fired the event (e.g., `${$source>/text}` returns the button text)
- **`$parameters`** — the event parameters defined by the UI5 control (e.g., `${$parameters>/id}` returns the element ID)
- **`$event`** — the UI5 event object itself (e.g., `$event>sId` returns the event type like `press`). Note: unlike the other two prefixes, `$event` is written without the `${...}` wrapper and without a leading `/` — see the [Event](#event) section below.

`arg` carries one value, which is what most events need. For two or more, use `t_arg` instead and pass them as a table — ``t_arg = VALUE #( ( `${$source>/text}` ) ( `${$parameters>/id}` ) )`` — and read them back in the same order with `client->get_event_arg( 2 )`, `( 3 )` and so on. The two are the same wire: `arg = x` is exactly ``t_arg = VALUE #( ( x ) )``.

For details, see the [UI5 docs on event handler arguments](https://openui5.hana.ondemand.com/#/topic/b0fb4de7364f4bcbb053a99aa645affe) and sample `Z2UI5_CL_SMP_APP_167`.

## Source
Expand All @@ -56,9 +58,9 @@ METHOD z2ui5_if_app~main.
)->tag( `Button`
)->a( n = `text` v = `post`
)->a( n = `press` v = client->_event(
val = `BUTTON_POST`
val = `BUTTON_POST`
" reads the button text → result: "post"
t_arg = VALUE #( ( `${$source>/text}` ) ) ) ).
arg = `${$source>/text}` ) ).

client->view_display( view->stringify( ) ).

Expand All @@ -85,9 +87,9 @@ METHOD z2ui5_if_app~main.
)->a( n = `id` v = `button_id`
)->a( n = `text` v = `post`
)->a( n = `press` v = client->_event(
val = `BUTTON_POST`
val = `BUTTON_POST`
" reads the event parameter 'id' → result: "mainView--button_id"
t_arg = VALUE #( ( `${$parameters>/id}` ) ) ) ).
arg = `${$parameters>/id}` ) ).

client->view_display( view->stringify( ) ).

Expand All @@ -113,9 +115,9 @@ METHOD z2ui5_if_app~main.
)->tag( `Button`
)->a( n = `text` v = `post`
)->a( n = `press` v = client->_event(
val = `BUTTON_POST`
val = `BUTTON_POST`
" reads an event-object attribute → result: "press"
t_arg = VALUE #( ( `$event>sId` ) ) ) ).
arg = `$event>sId` ) ).

client->view_display( view->stringify( ) ).

Expand Down Expand Up @@ -157,8 +159,8 @@ CLASS z2ui5_cl_app_hello_world IMPLEMENTATION.
)->tag( `Button`
)->a( n = `text` v = `post`
)->a( n = `press` v = client->_event(
val = `BUTTON_POST`
t_arg = VALUE #( ( `$` && client->_bind( name ) ) ) ) ).
val = `BUTTON_POST`
arg = `$` && client->_bind( name ) ) ).

client->view_display( view->stringify( ) ).

Expand Down
4 changes: 1 addition & 3 deletions docs/cookbook/expert_more/value_help.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ CLASS z2ui5_cl_sample_f4 IMPLEMENTATION.
)->a( n = `title` v = `{CARRNAME}`
)->a( n = `description` v = `{CARRID}`
)->a( n = `type` v = `Active`
)->a( n = `press` v = client->_event(
val = `PICK`
t_arg = VALUE #( ( `${CARRID}` ) ) ) ).
)->a( n = `press` v = client->_event( val = `PICK` arg = `${CARRID}` ) ).

client->popup_display( popup->stringify( ) ).

Expand Down
3 changes: 1 addition & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,7 @@ CLASS zcl_app_invoices IMPLEMENTATION.
)->tag( `Button`
)->a( n = `icon` v = `sap-icon://edit`
)->a( n = `tooltip` v = `Edit delivery date`
)->a( n = `press` v = client->_event( val = `EDIT`
t_arg = VALUE #( ( `${PRODUCT}` ) ) ) ).
)->a( n = `press` v = client->_event( val = `EDIT` arg = `${PRODUCT}` ) ).

client->view_display( view->stringify( ) ).

Expand Down
5 changes: 2 additions & 3 deletions docs/tutorials/walkthrough/step-10.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ CLASS zcl_app_walkthrough IMPLEMENTATION.
METHOD on_event.

" get_event( ) holds the name passed to _event( );
" get_event_arg( ) returns the extra argument attached via t_arg
" get_event_arg( ) returns the extra argument attached via arg
CASE client->get_event( ).
WHEN `READ`.
data_read( ).
Expand Down Expand Up @@ -177,8 +177,7 @@ CLASS zcl_app_walkthrough IMPLEMENTATION.
)->tag( `Button`
)->a( n = `icon` v = `sap-icon://edit`
)->a( n = `tooltip` v = `Edit delivery date`
)->a( n = `press` v = client->_event( val = `EDIT`
t_arg = VALUE #( ( `${PRODUCT}` ) ) ) ).
)->a( n = `press` v = client->_event( val = `EDIT` arg = `${PRODUCT}` ) ).

client->view_display( view->stringify( ) ).

Expand Down
5 changes: 2 additions & 3 deletions docs/tutorials/walkthrough/step-12.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ CLASS zcl_app_walkthrough IMPLEMENTATION.
METHOD on_event.

" get_event( ) holds the name passed to _event( );
" get_event_arg( ) returns the extra argument attached via t_arg
" get_event_arg( ) returns the extra argument attached via arg
CASE client->get_event( ).
WHEN `READ`.
data_read( ).
Expand Down Expand Up @@ -173,8 +173,7 @@ CLASS zcl_app_walkthrough IMPLEMENTATION.
)->tag( `Button`
)->a( n = `icon` v = `sap-icon://edit`
)->a( n = `tooltip` v = `Edit delivery date`
)->a( n = `press` v = client->_event( val = `EDIT`
t_arg = VALUE #( ( `${PRODUCT}` ) ) ) ).
)->a( n = `press` v = client->_event( val = `EDIT` arg = `${PRODUCT}` ) ).

client->view_display( view->stringify( ) ).

Expand Down
15 changes: 8 additions & 7 deletions docs/tutorials/walkthrough/step-6.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ CLASS zcl_app_walkthrough IMPLEMENTATION.
)->a( n = `description` v = `{SUPPLIER}`
)->a( n = `info` v = `{QUANTITY}`
)->a( n = `type` v = `Active`
)->a( n = `press` v = client->_event( val = `SHOW_INVOICE`
t_arg = VALUE #( ( `${PRODUCT}` ) ) ) ).
)->a( n = `press` v = client->_event( val = `SHOW_INVOICE` arg = `${PRODUCT}` ) ).

client->view_display( view->stringify( ) ).

Expand All @@ -80,11 +79,13 @@ ENDCLASS.
- **`type = Active`** makes the whole row clickable and gives it press
feedback; the `press` handler sits on the row template, so every row fires
the same event.
- **The argument rides with the event:**
``t_arg = VALUE #( ( `${PRODUCT}` ) )``. The `${...}` syntax is resolved
*per row* in the browser — each clone of the template carries its own
product name. On the server, `client->get_event_arg( )` returns it, and a
table read finds the row.
- **The argument rides with the event:** ``arg = `${PRODUCT}` ``. The
`${...}` syntax is resolved *per row* in the browser — each clone of the
template carries its own product name. On the server,
`client->get_event_arg( )` returns it, and a table read finds the row.
`arg` is the one-value spelling of `t_arg`: it is exactly
``t_arg = VALUE #( ( `${PRODUCT}` ) )``, and from two values on `t_arg` is
the parameter to use.
- **The state is still there.** `t_invoices` was filled in the
`check_on_navigated` branch of an earlier roundtrip — the framework
restored it before this one, so the event handler can read it. That is the
Expand Down
3 changes: 1 addition & 2 deletions docs/tutorials/walkthrough/step-7.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ CLASS zcl_app_walkthrough IMPLEMENTATION.
)->a( n = `description` v = `{SUPPLIER}`
)->a( n = `info` v = `{QUANTITY}`
)->a( n = `type` v = `Active`
)->a( n = `press` v = client->_event( val = `EDIT`
t_arg = VALUE #( ( `${PRODUCT}` ) ) ) ).
)->a( n = `press` v = client->_event( val = `EDIT` arg = `${PRODUCT}` ) ).

client->view_display( view->stringify( ) ).

Expand Down
3 changes: 1 addition & 2 deletions docs/tutorials/walkthrough/step-9.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ CLASS zcl_app_walkthrough IMPLEMENTATION.
)->tag( `Button`
)->a( n = `icon` v = `sap-icon://edit`
)->a( n = `tooltip` v = `Edit delivery date`
)->a( n = `press` v = client->_event( val = `EDIT`
t_arg = VALUE #( ( `${PRODUCT}` ) ) ) ).
)->a( n = `press` v = client->_event( val = `EDIT` arg = `${PRODUCT}` ) ).

client->view_display( view->stringify( ) ).

Expand Down
Loading