Skip to content

Commit 6813029

Browse files
committed
Add inline comments to formatter.md and lifecycle diagram to hello_world.md
- formatter.md: add ABAP inline comments before each binding variant explaining what it does (one-field vs two-field, showMeasure/showNumber, preserveDecimals, currencyCode, style short/long, digit sequence), plus resolved UI5 output for the OData type section - hello_world.md: add ASCII flow diagram showing the roundtrip lifecycle (browser→main()→browser loop) to visualize that main is called on every user interaction https://claude.ai/code/session_01AaA4EMw83KMzGP6kaDZPJU
1 parent f933b31 commit 6813029

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

docs/development/specific/formatter.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,19 @@ CLASS z2ui5_cl_demo_app_067 IMPLEMENTATION.
6262
)->label( `Documentation`
6363
)->link( text = `https://sapui5.hana.ondemand.com/#/entity/sap.ui.model.type.Currency`
6464
href = `https://sapui5.hana.ondemand.com/#/entity/sap.ui.model.type.Currency`
65+
66+
"Currency in one field — shows amount and currency symbol together
67+
"resolves to: { parts: ["/XX/AMOUNT", "/XX/CURRENCY"], type: 'sap.ui.model.type.Currency' }
6568
)->label( `One field`
6669
)->input(
6770
|\{ parts: [ `{ client->_bind_edit( val = amount
6871
path = abap_true ) }`, `{ client->_bind_edit(
6972
val = currency
7073
path = abap_true ) }`], type: 'sap.ui.model.type.Currency' \}|
74+
75+
"Split into two fields — first shows only the number, second only the currency
76+
"showMeasure: false → hides the currency symbol
77+
"showNumber: false → hides the numeric value
7178
)->label( `Two field`
7279
)->input(
7380
|\{ parts: [ `{ client->_bind_edit( val = amount
@@ -79,30 +86,40 @@ CLASS z2ui5_cl_demo_app_067 IMPLEMENTATION.
7986
path = abap_true ) }`, `{ client->_bind_edit(
8087
val = currency
8188
path = abap_true ) }`], type: 'sap.ui.model.type.Currency' , formatOptions: \{showNumber: false\} \}|
89+
90+
"Read-only display variants with different formatOptions
8291
)->label( `Default`
8392
)->text(
8493
|\{ parts: [ `{ client->_bind_edit( val = amount
8594
path = abap_true ) }`, `{ client->_bind_edit(
8695
val = currency
8796
path = abap_true ) }`], type: 'sap.ui.model.type.Currency' \}|
97+
98+
"preserveDecimals: false → trims trailing zeros (e.g. 123,456,789.12 USD)
8899
)->label( `preserveDecimals:false`
89100
)->text( |\{ parts: [ `{ client->_bind_edit( val = amount
90101
path = abap_true ) }`, `| && client->_bind_edit(
91102
val = currency
92103
path = abap_true ) &&
93104
|`], type: 'sap.ui.model.type.Currency' , formatOptions: \{ preserveDecimals : false \} \}|
105+
106+
"currencyCode: false → hides the ISO code, shows only the number
94107
)->label( `currencyCode:false`
95108
)->text( |\{ parts: [ `{ client->_bind_edit( val = amount
96109
path = abap_true ) }`, `| && client->_bind_edit(
97110
val = currency
98111
path = abap_true ) &&
99112
|`], type: 'sap.ui.model.type.Currency' , formatOptions: \{ currencyCode : false \} \}|
113+
114+
"style: 'short' → compact notation (e.g. 123M USD)
100115
)->label( `style:'short'`
101116
)->text(
102117
|\{ parts: [ `{ client->_bind_edit( val = amount
103118
path = abap_true ) }`, `{ client->_bind_edit(
104119
val = currency
105120
path = abap_true ) }`], type: 'sap.ui.model.type.Currency' , formatOptions: \{ style : 'short' \} \}|
121+
122+
"style: 'long' → full text notation (e.g. 123 million US dollars)
106123
)->label( `style:'long'`
107124
)->text(
108125
|\{ parts: [ `{ client->_bind_edit( val = amount
@@ -113,6 +130,9 @@ CLASS z2ui5_cl_demo_app_067 IMPLEMENTATION.
113130
)->button( text = `send`
114131
press = client->_event( `BUTTON` ) ).
115132
133+
"Remove leading zeros from a numeric string using OData type formatting
134+
"isDigitSequence: true tells the formatter to treat the value as a digit sequence
135+
"resolves to: { path: "/XX/NUMERIC", type: 'sap.ui.model.odata.type.String', constraints: { isDigitSequence: true } }
116136
page->simple_form( title = `No Zeros`
117137
editable = abap_true
118138
)->content( `form`

docs/get_started/hello_world.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,27 @@ ENDCLASS.
5555
```
5656

5757
### Event Handler
58-
The `main` method is called on every roundtrip — that is, on initialization and after every user interaction (button press, input submit, etc.). To control what happens when, use `CASE abap_true` to distinguish between lifecycle events:
58+
The `main` method is called on every roundtrip — that is, on initialization and after every user interaction (button press, input submit, etc.):
59+
60+
```
61+
┌─────────┐ ┌──────────┐ ┌─────────┐
62+
│ Browser │──────>│ main() │──────>│ Browser │
63+
│ (Start) │ HTTP │ init │ HTTP │ (View) │
64+
└─────────┘ └──────────┘ └────┬─────┘
65+
│ user clicks
66+
┌─────────┐ ┌──────────┐ ┌────┴─────┐
67+
│ Browser │<──────│ main() │<──────│ Browser │
68+
│ (Update) │ HTTP │ event │ HTTP │ (Event) │
69+
└─────────┘ └──────────┘ └──────────┘
70+
```
71+
72+
To control what happens when, use `CASE abap_true` to distinguish between lifecycle events:
5973

6074
- `client->check_on_init( )` — first call when the app starts
6175
- `client->check_on_event( )` — user triggered an event (e.g. button press)
6276
- `client->check_on_navigated( )` — returned from another app via navigation
6377

64-
This pattern works because each `check_*` method returns `abap_true` only for its specific phase, making `CASE abap_true` act as a dispatcher:
78+
Each `check_*` method returns `abap_true` only for its specific phase, making `CASE abap_true` act as a dispatcher:
6579
```abap
6680
CLASS zcl_app_hello_world DEFINITION PUBLIC.
6781
PUBLIC SECTION.

0 commit comments

Comments
 (0)