Skip to content

Commit 868b9cf

Browse files
committed
Document XML/fluent-API mapping and generic view builder
Rename Expert, More to Beyond Basics
1 parent 29a5b8c commit 868b9cf

2 files changed

Lines changed: 41 additions & 1 deletion

File tree

docs/.vitepress/config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ export default defineConfig({
226226
],
227227
},
228228
{
229-
text: "Expert, More",
229+
text: "Beyond Basics",
230230
link: "/cookbook/expert_more/lock",
231231
collapsed: true,
232232
items: [

docs/cookbook/view/definition.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,45 @@ Combining controls in a way that violates these rules can lead to broken renderi
5252
The ABAP compiler cannot catch these mistakes — they are pure UI5 concerns and must be verified against the SDK documentation.
5353
:::
5454

55+
## Mapping UI5 XML ↔ ABAP Fluent API
56+
57+
`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:
58+
59+
- Control names follow snake_case of the UI5 control class — `sap.m.MultiComboBox` becomes `->multi_combo_box( )`, `sap.m.Text` becomes `->text( )`.
60+
- Properties are passed as named parameters in snake_case (`enabled`, `placeholder`, `selected_key`).
61+
- Aggregations are exposed as methods named after the aggregation itself (`->items( )`, `->content( )`, `->custom_data( )`) — not as `add_item( )` / `add_content( )`. Calling the aggregation method returns the parent builder so you can chain children inside it.
62+
- Coverage is incomplete and occasionally inconsistent: some controls or properties are missing, some method signatures don't match the SDK exactly. When in doubt, check the source of `Z2UI5_CL_XML_VIEW` or fall back to the generic builder below.
63+
64+
### The Fully Generic Builder
65+
66+
Every fluent helper ultimately produces an XML element. The lowest-level method `_generic( name = ... ns = ... )` lets you emit **any** XML element with **any** attributes, regardless of whether `Z2UI5_CL_XML_VIEW` knows the control:
67+
68+
```abap
69+
DATA(view) = z2ui5_cl_xml_view=>factory( ).
70+
71+
view->_generic( name = `Page` ns = `sap.m`
72+
)->_generic( name = `MultiComboBox` ns = `sap.m`
73+
t_prop = VALUE #(
74+
( n = `selectedKeys` v = `{/keys}` )
75+
( n = `placeholder` v = `Pick one` )
76+
)
77+
)->_generic( name = `items` ns = `sap.m`
78+
)->_generic( name = `core:Item` ns = `sap.ui.core`
79+
t_prop = VALUE #(
80+
( n = `key` v = `{key}` )
81+
( n = `text` v = `{text}` )
82+
) ).
83+
84+
client->view_display( view->stringify( ) ).
85+
```
86+
87+
This maps **1:1** to the UI5 XML/SDK API — control names, property names, and aggregation names are written exactly as they appear in the [UI5 SDK](https://sapui5.hana.ondemand.com), in their original camelCase. There is no abstraction layer guessing what to call things.
88+
89+
::: tip Recommended for AI-assisted Development
90+
For AI-assisted coding, prefer the generic builder. It removes the need for the model to know the abap2UI5 naming conventions or guess which controls and properties are wrapped — the SDK documentation can be used directly. The fluent API in `Z2UI5_CL_XML_VIEW` is convenient for humans but its inconsistencies and incomplete coverage make it a poor target for code generation.
91+
:::
92+
93+
The rest of this documentation uses the higher-level fluent API (`->page( )`, `->button( )`, `->multi_combo_box( )`) because it reads better in examples. Both styles can be mixed freely in the same view.
94+
5595
#### Next Steps
5696
This produces a static view. The next section walks through binding and sharing data between the view and the app logic.

0 commit comments

Comments
 (0)