Skip to content

Commit 992b040

Browse files
authored
Merge pull request #96 from abap2UI5/claude/laughing-ramanujan-TCi3v
Refactor device info docs and reorganize view section
2 parents f94b70c + f9f6c3e commit 992b040

10 files changed

Lines changed: 176 additions & 143 deletions

File tree

docs/.vitepress/config.mjs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,9 @@ export default defineConfig({
124124
items: [
125125
{
126126
text: "View",
127-
link: "/cookbook/view/overview",
127+
link: "/cookbook/view/definition",
128128
collapsed: true,
129129
items: [
130-
{ text: "Overview", link: "/cookbook/view/overview" },
131130
{ text: "Definition", link: "/cookbook/view/definition" },
132131
{ text: "Nested Views", link: "/cookbook/view/nested_views" },
133132
{ text: "XML Templating", link: "/cookbook/view/xml_templating" },
@@ -142,7 +141,7 @@ export default defineConfig({
142141
text: "Binding",
143142
link: "/cookbook/model/binding",
144143
items: [
145-
{ text: "Expression Binding", link: "/cookbook/model/expression_binding" },
144+
{ text: "Expressions", link: "/cookbook/model/expression_binding" },
146145
{ text: "Formatter", link: "/cookbook/model/formatter" },
147146
],
148147
},
@@ -188,7 +187,7 @@ export default defineConfig({
188187
items: [
189188
{ text: "Message", link: "/cookbook/translation_messages/message" },
190189
{ text: "Logging", link: "/cookbook/translation_messages/logging" },
191-
{ text: "Translation, i18n", link: "/cookbook/translation_messages/translation_i18n" },
190+
{ text: "Translation", link: "/cookbook/translation_messages/translation_i18n" },
192191
],
193192
},
194193
{
@@ -202,6 +201,7 @@ export default defineConfig({
202201
{ text: "Timer", link: "/cookbook/browser_interaction/timer" },
203202
{ text: "Clipboard", link: "/cookbook/browser_interaction/clipboard" },
204203
{ text: "URL Handling", link: "/cookbook/browser_interaction/url_handling" },
204+
{ text: "Soft Keyboard", link: "/cookbook/browser_interaction/soft_keyboard" },
205205
],
206206
},
207207
{
@@ -215,11 +215,11 @@ export default defineConfig({
215215
text: "Geolocation",
216216
link: "/cookbook/device_capabilities/geolocation",
217217
},
218-
{ text: "Soft Keyboard", link: "/cookbook/device_capabilities/soft_keyboard" },
219218
{
220219
text: "Barcode Scanning",
221220
link: "/cookbook/device_capabilities/barcode_scanning",
222221
},
222+
{ text: "Audio", link: "/cookbook/device_capabilities/audio" },
223223
{
224224
text: "Upload, Download",
225225
link: "/cookbook/device_capabilities/upload_download",
@@ -236,7 +236,7 @@ export default defineConfig({
236236
collapsed: true,
237237
items: [
238238
{
239-
text: "Advanced",
239+
text: "Sessions, Communication",
240240
collapsed: true,
241241
items: [
242242
{ text: "Lock", link: "/cookbook/expert_more/lock" },
@@ -284,7 +284,7 @@ export default defineConfig({
284284
items: [
285285
{ text: "Custom Controls", link: "/cookbook/expert_more/custom_controls" },
286286
{ text: "Custom JS", link: "/cookbook/expert_more/custom_js" },
287-
{ text: "follow_up_action", link: "/cookbook/expert_more/follow_up_action" },
287+
{ text: "Follow-up Action", link: "/cookbook/expert_more/follow_up_action" },
288288
],
289289
},
290290
],
File renamed without changes.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
outline: [2, 4]
3+
---
4+
# Audio
5+
6+
#### Play Sounds
7+
8+
Audio feedback is handy in some scenarios. Fire the `play_audio` frontend event with the URL of a sound file — for example a `.wav` from the SAP MIME repository at `/SAP/PUBLIC/BC/ABAP/mime_demo/bam.wav`:
9+
10+
```abap
11+
CLASS z2ui5_cl_sample_sound DEFINITION PUBLIC.
12+
13+
PUBLIC SECTION.
14+
INTERFACES z2ui5_if_app.
15+
DATA company_code TYPE string.
16+
17+
ENDCLASS.
18+
19+
CLASS z2ui5_cl_sample_sound IMPLEMENTATION.
20+
METHOD z2ui5_if_app~main.
21+
22+
IF client->check_on_init( ).
23+
24+
DATA(view) = z2ui5_cl_xml_view=>factory( ).
25+
DATA(vbox) = view->page( )->vbox( ).
26+
vbox->input( id = `inputApp`
27+
value = client->_bind_edit( company_code )
28+
type = `Number`
29+
placeholder = `Company Code`
30+
submit = client->_event( `CHECK_INPUT` ) ).
31+
vbox->button( text = `check`
32+
press = client->_event( `CHECK_INPUT` ) ).
33+
34+
client->view_display( view->stringify( ) ).
35+
RETURN.
36+
ENDIF.
37+
38+
IF client->get( )-event = `CHECK_INPUT`.
39+
IF company_code IS INITIAL.
40+
client->action( val = client->cs_event-play_audio
41+
t_arg = VALUE #( ( `/SAP/PUBLIC/BC/ABAP/mime_demo/bam.wav` ) ) ).
42+
client->message_box_display( type = `error` text = `Input is empty!` ).
43+
ELSE.
44+
CLEAR company_code.
45+
ENDIF.
46+
client->view_model_update( ).
47+
ENDIF.
48+
49+
ENDMETHOD.
50+
ENDCLASS.
51+
```
52+
For a complete sound sample, see `Z2UI5_CL_DEMO_APP_304`.

docs/cookbook/device_capabilities/info.md

Lines changed: 64 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3,63 +3,75 @@ outline: [2, 4]
33
---
44
# Info
55

6-
abap2UI5 offers a custom control for reading all frontend information from the user's device — UI5 version and theme, browser, operating system, system type, screen dimensions, and device class (phone, tablet, desktop). This is handy whenever your ABAP logic needs to adapt to the runtime environment.
6+
abap2UI5 ships the current frontend state with every roundtrip. Read it from `client->get( )` — no custom control, no extra event needed. The relevant sub-structures are `s_device`, `s_ui5`, `s_focus`, and `s_scroll`.
77

8-
The control collects the values on the frontend and returns them via two-way binding. Once the `finished` event fires, all bound attributes are filled and available to ABAP. See also `Z2UI5_CL_DEMO_APP_122`.
8+
#### Device
9+
10+
`client->get( )-s_device` describes the user's device and browser: operating system, browser name and version, screen orientation, current viewport size, and capability flags (touch, pointer, retina).
911

1012
```abap
11-
CLASS z2ui5_cl_sample_frontend_info DEFINITION PUBLIC.
12-
13-
PUBLIC SECTION.
14-
INTERFACES z2ui5_if_app.
15-
16-
DATA ui5_version TYPE string.
17-
DATA ui5_theme TYPE string.
18-
DATA ui5_gav TYPE string.
19-
DATA device_systemtype TYPE string.
20-
DATA device_os TYPE string.
21-
DATA device_browser TYPE string.
22-
DATA device_phone TYPE abap_bool.
23-
DATA device_desktop TYPE abap_bool.
24-
DATA device_tablet TYPE abap_bool.
25-
DATA device_combi TYPE abap_bool.
26-
DATA device_height TYPE string.
27-
DATA device_width TYPE string.
28-
29-
ENDCLASS.
30-
31-
CLASS z2ui5_cl_sample_frontend_info IMPLEMENTATION.
32-
33-
METHOD z2ui5_if_app~main.
34-
35-
DATA(view) = z2ui5_cl_xml_view=>factory( ).
36-
client->view_display( view->shell(
37-
)->page( )->_z2ui5(
38-
)->info_frontend(
39-
finished = client->_event( `POST` )
40-
device_browser = client->_bind_edit( device_browser )
41-
device_os = client->_bind_edit( device_os )
42-
device_systemtype = client->_bind_edit( device_systemtype )
43-
ui5_gav = client->_bind_edit( ui5_gav )
44-
ui5_theme = client->_bind_edit( ui5_theme )
45-
ui5_version = client->_bind_edit( ui5_version )
46-
device_phone = client->_bind_edit( device_phone )
47-
device_desktop = client->_bind_edit( device_desktop )
48-
device_tablet = client->_bind_edit( device_tablet )
49-
device_combi = client->_bind_edit( device_combi )
50-
device_height = client->_bind_edit( device_height )
51-
device_width = client->_bind_edit( device_width )
52-
)->stringify( ) ).
53-
54-
CASE client->get( )-event.
55-
WHEN `POST`.
56-
"process frontend info here...
57-
ENDCASE.
58-
59-
ENDMETHOD.
60-
ENDCLASS.
13+
DATA(device) = client->get( )-s_device.
14+
15+
DATA(system) = device-system. " e.g. `desktop`, `phone`, `tablet`
16+
DATA(orientation) = device-orientation. " `landscape` | `portrait`
17+
18+
DATA(browser) = device-browser-name. " e.g. `chrome`
19+
DATA(brw_version) = device-browser-version.
20+
21+
DATA(os) = device-os-name. " e.g. `win`, `mac`, `ios`, `android`
22+
DATA(os_version) = device-os-version.
23+
24+
DATA(width) = device-resize-width. " current viewport, in px
25+
DATA(height) = device-resize-height.
26+
27+
DATA(touch) = device-support-touch.
28+
DATA(pointer) = device-support-pointer.
29+
DATA(retina) = device-support-retina.
6130
```
6231

6332
::: tip **Bind Directly in the View**
6433
If you only need device information in the view (not in ABAP logic), bind to the built-in UI5 device model via `{device>/...}` instead — no backend roundtrip required. See [Device Model](../model/device_model.md).
6534
:::
35+
36+
#### UI5
37+
38+
`client->get( )-s_ui5` returns the runtime UI5 framework details — handy for version-dependent branching or for logging which build a user runs on.
39+
40+
```abap
41+
DATA(ui5) = client->get( )-s_ui5.
42+
43+
DATA(version) = ui5-version. " e.g. `1.141.0`
44+
DATA(build_timestamp) = ui5-build_timestamp.
45+
DATA(gav) = ui5-gav. " group, artifact, version
46+
DATA(theme) = ui5-theme. " e.g. `sap_horizon`
47+
```
48+
49+
#### Focus
50+
51+
`client->get( )-s_focus` tells you which control currently holds the focus and where the caret sits inside it. Useful when an action depends on the field the user was just editing.
52+
53+
```abap
54+
DATA(focus) = client->get( )-s_focus.
55+
56+
DATA(id) = focus-id. " id of the focused control
57+
DATA(selection_start) = focus-selection_start. " caret start, in chars
58+
DATA(selection_end) = focus-selection_end. " caret end, in chars
59+
```
60+
61+
To move the focus from the backend instead of reading it, see [Focus](../browser_interaction/focus.md).
62+
63+
#### Scroll
64+
65+
`client->get( )-s_scroll` reports the scroll positions of the page and any open dialogs at the moment the event was fired. Each container exposes the id of the scrollable element and its `x` / `y` offsets in pixels.
66+
67+
```abap
68+
DATA(scroll) = client->get( )-s_scroll.
69+
70+
DATA(main_y) = scroll-main-y. " main page
71+
DATA(nest_y) = scroll-nest-y. " first nested view
72+
DATA(nest2_y) = scroll-nest2-y. " second nested view
73+
DATA(popup_y) = scroll-popup-y. " open popup
74+
DATA(popover_y) = scroll-popover-y. " open popover
75+
```
76+
77+
To scroll from the backend, see [Scrolling](../browser_interaction/scrolling.md).

docs/cookbook/expert_more/custom_controls.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ The table below lists custom controls that are no longer necessary and the built
1919
| Scroll to a position | `cs_event-scroll_to` | [Scrolling](/cookbook/browser_interaction/scrolling) |
2020
| Scroll an element into view| `cs_event-scroll_into_view` | [Scrolling](/cookbook/browser_interaction/scrolling) |
2121
| Start a timer | `cs_event-start_timer` | [Timer](/cookbook/browser_interaction/timer) |
22-
| Toggle the soft keyboard | `cs_event-keyboard_set_mode` | [Soft Keyboard](/cookbook/device_capabilities/soft_keyboard) |
22+
| Toggle the soft keyboard | `cs_event-keyboard_set_mode` | [Soft Keyboard](/cookbook/browser_interaction/soft_keyboard) |
23+
| Read frontend info | `client->get( )-s_device`, `-s_ui5`, `-s_focus`, `-s_scroll` | [Info](/cookbook/device_capabilities/info) |
2324

2425
## Typical Pattern
2526

docs/cookbook/expert_more/follow_up_action.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
outline: [2, 4]
33
---
4-
# follow_up_action (Obsolete)
4+
# Follow-up Action (Obsolete)
55

66
::: warning Do Not Use Anymore
77
`client->follow_up_action( )` is obsolete. Use `client->action( )` instead. It works the same way, but **does not allow sending arbitrary JavaScript to the frontend** — which is exactly why `follow_up_action` was deprecated. See [Custom JS](/cookbook/expert_more/custom_js) for the full reasoning behind removing direct JS execution.

docs/cookbook/model/expression_binding.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
outline: [2, 4]
33
---
4-
# Expression Binding
4+
# Expressions
55

66
Expression Binding lets you compute values directly in XML views with JavaScript-like expressions. This is especially handy in abap2UI5, since it cuts server roundtrips by moving calculations, logical conditions, and string operations to the frontend.
77

docs/cookbook/translation_messages/translation_i18n.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
outline: [2, 4]
33
---
4-
# Translation, i18n
4+
# Translation
55

66
Standard UI5 apps handle translations with i18n files stored as frontend artifacts. Since abap2UI5 apps live entirely on the ABAP backend, use ABAP's built-in translation tools instead — text elements, message classes, or data element descriptions.
77

docs/cookbook/view/definition.md

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ outline: [2, 4]
33
---
44
# Definition
55

6-
In abap2UI5, UI5 renders the UI from an XML view that you build in ABAP. A simple example with raw XML:
6+
abap2UI5 uses [SAP UI5](https://sapui5.hana.ondemand.com) on the frontend without modification. Whatever your ABAP code sends to the browser is a **standard UI5 XML view** — the same XML you would write in any UI5 freestyle project.
7+
8+
The consequence: **everything in the UI5 SDK works in abap2UI5 1:1**. Any control, any property, any namespace from the [UI5 Demo Kit](https://sapui5.hana.ondemand.com/sdk) is available. Copy the XML, paste it into your ABAP class, and it renders.
9+
10+
#### Sending a View
11+
12+
The simplest case: build an XML string and ship it to the client.
713

814
```abap
915
METHOD z2ui5_if_app~main.
@@ -20,7 +26,12 @@ In abap2UI5, UI5 renders the UI from an XML view that you build in ABAP. A simpl
2026
2127
ENDMETHOD.
2228
```
23-
You can use any UI5 control from the [UI5 SDK](https://sapui5.hana.ondemand.com). But writing raw XML quickly turns cumbersome. A handier approach is the `Z2UI5_CL_XML_VIEW` helper class, with a fluent API for building views. The `stringify( )` method at the end converts the view tree into an XML string that the framework sends to the frontend:
29+
30+
Swap `<Text>` for any other control from the SDK; the framework doesn't care.
31+
32+
#### Helper Class
33+
34+
Writing raw XML by hand quickly turns cumbersome. abap2UI5 ships the helper class `z2ui5_cl_xml_view` with a fluent API that mirrors the XML structure and gives you code completion. The `stringify( )` method at the end converts the view tree into an XML string that the framework sends to the frontend:
2435

2536
```abap
2637
METHOD z2ui5_if_app~main.
@@ -35,6 +46,8 @@ You can use any UI5 control from the [UI5 SDK](https://sapui5.hana.ondemand.com)
3546
ENDMETHOD.
3647
```
3748

49+
Both snippets produce the exact same view. Use whichever you prefer — raw strings are fine for a handful of lines, the fluent API scales better for real apps.
50+
3851
Tips for working with views:
3952
- Use code completion on `Z2UI5_CL_XML_VIEW` to find controls and properties
4053
- See the [samples repository](/get_started/next#sample-apps) for ready-made XML examples to copy and adapt
@@ -52,6 +65,39 @@ Combining controls in a way that violates these rules can lead to broken renderi
5265
The ABAP compiler cannot catch these mistakes — they are pure UI5 concerns and must be verified against the SDK documentation.
5366
:::
5467

68+
#### Where to Look for Controls
69+
70+
Because UI5 XML is used 1:1, **the UI5 documentation is your reference** for anything visual:
71+
72+
- [UI5 Demo Kit](https://sapui5.hana.ondemand.com/sdk) — interactive samples for every control
73+
- [UI5 Control API](https://sapui5.hana.ondemand.com/sdk/#/api) — properties, aggregations, events
74+
75+
Find a control you like in the UI5 docs, copy its XML, paste it into `view_display( )` — done. abap2UI5 has no separate control catalog to learn.
76+
77+
#### Choosing a Control
78+
79+
The UI5 SDK is large. The table below covers the choices that come up in almost every abap2UI5 app — use it as a starting point before diving into the SDK.
80+
81+
| Need | Use | Notes |
82+
| --------------------------------- | ----------------------------------------------------- | ---------------------------------------------------------------------------------- |
83+
| Tabular data, columns, sorting | `sap.m.Table` | Responsive, supports growing/p13n. Default choice for business data. |
84+
| Flat list with icons/avatars | `sap.m.List` with `StandardListItem` | Lighter than `Table` when columns are not needed. |
85+
| Hierarchical data (parent/child) | `sap.m.Tree` or `sap.ui.table.TreeTable` | `Tree` is responsive; `TreeTable` shows fixed columns. |
86+
| Form with labels + inputs | `sap.ui.layout.form.SimpleForm` | Use this 90% of the time — auto-layouts labels and fields responsively. |
87+
| Form with custom grid layout | `sap.ui.layout.form.Form` | When `SimpleForm` is not flexible enough. |
88+
| App page with title and content | `sap.m.Page` | The standard container. Wrap in `sap.m.Shell` for the SAP frame. |
89+
| Page with collapsible header | `sap.f.DynamicPage` | For object pages and analytics screens. |
90+
| Page with action toolbar | `sap.f.semantic.SemanticPage` | Adds semantic actions (edit, delete, share) in the footer. |
91+
| Vertical / horizontal stack | `sap.m.VBox` / `sap.m.HBox` | Quick layout without a form. |
92+
| Tabs | `sap.m.IconTabBar` | Use `IconTabFilter` for each tab. |
93+
| Single-select dropdown | `sap.m.Select` (≤ 20 items) / `sap.m.ComboBox` | `ComboBox` allows typing and filtering. |
94+
| Multi-select dropdown | `sap.m.MultiComboBox` | Pills appear inside the field. |
95+
| Date / time input | `sap.m.DatePicker` / `sap.m.TimePicker` / `sap.m.DateTimePicker` | Needs a formatter — see [Binding → Data-Type Mapping](/cookbook/model/binding#data-type-mapping). |
96+
| Status indicator | `sap.m.ObjectStatus` | Colored text + icon for state. |
97+
| Modal dialog | `sap.m.Dialog` (built with `factory_popup`) | See [Popover](/cookbook/popup_popover/popover). |
98+
99+
When two controls fit, prefer the simpler one: `Table` over `TreeTable`, `SimpleForm` over `Form`, `Select` over `ComboBox`. Switch to the richer variant only when a concrete requirement justifies it.
100+
55101
## Mapping UI5 XML ↔ ABAP Fluent API
56102

57103
`Z2UI5_CL_XML_VIEW` is a hand-curated wrapper around UI5 controls. It does not cover every UI5 control, and the naming is not always a strict 1:1 mapping of the UI5 SDK:

0 commit comments

Comments
 (0)