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
Copy file name to clipboardExpand all lines: docs/cookbook/view/definition.md
+40Lines changed: 40 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,5 +52,45 @@ Combining controls in a way that violates these rules can lead to broken renderi
52
52
The ABAP compiler cannot catch these mistakes — they are pure UI5 concerns and must be verified against the SDK documentation.
53
53
:::
54
54
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
+
55
95
#### Next Steps
56
96
This produces a static view. The next section walks through binding and sharing data between the view and the app logic.
0 commit comments