Skip to content

Commit 784d180

Browse files
authored
fix: replace binding type usage from global namespace (#111)
1 parent a66ab14 commit 784d180

File tree

30 files changed

+354
-222
lines changed

30 files changed

+354
-222
lines changed

steps/20/README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,15 @@ export default class App extends Controller {
4646

4747
We add the invoice list controller to the view to get access to the view model we defined in the controller.
4848

49-
We add a price and the currency to our invoices list in the view by adding the `number` attribute to the `ObjectListItem` control, then we apply the currency data type on the number by setting the `type` attribute of the binding syntax to `sap.ui.model.type.Currency`. The `Currency` type will handle the formatting of the price for us, based on the currency code. In our case, the price is displayed with 2 decimals.
49+
We add a price and the currency to our invoices list in the view by adding the `number` attribute to the `ObjectListItem` control. To apply the currency data type, we use the `require` attribute with the namespace URI `sap.ui.core`, for which the prefix `core` is already defined in our XML view. This allows us to write the attribute as `core:require`. We then add the currency data type module to the list of required modules and assign it the alias `Currency`, making it available for use within the view. Then we set the `type` attribute of the binding syntax to the alias `Currency`. The `Currency` type will handle the formatting of the price for us, based on the currency code. In our case, the price is displayed with 2 decimals.
5050

5151
Additionally, we set the formatting option `showMeasure` to `false`. This hides the currency code in the property `number`. Instead we pass the currency on to the `ObjectListItem` control as a separate property `numberUnit`.
5252

5353
```xml
5454
<mvc:View
5555
controllerName="ui5.walkthrough.controller.InvoiceList"
5656
xmlns="sap.m"
57+
xmlns:core="sap.ui.core"
5758
xmlns:mvc="sap.ui.core.mvc">
5859
<List
5960
headerText="{i18n>invoiceListTitle}"
@@ -62,13 +63,16 @@ Additionally, we set the formatting option `showMeasure` to `false`. This hides
6263
items="{invoice>/Invoices}" >
6364
<items>
6465
<ObjectListItem
66+
core:require="{
67+
Currency: 'sap/ui/model/type/Currency'
68+
}"
6569
title="{invoice>Quantity} x {invoice>ProductName}"
6670
number="{
6771
parts: [
6872
'invoice>ExtendedPrice',
6973
'view>/currency'
7074
],
71-
type: 'sap.ui.model.type.Currency',
75+
type: 'Currency',
7276
formatOptions: {
7377
showMeasure: false
7478
}
@@ -102,6 +106,8 @@ As you can see above, we are using a special binding syntax for the `number` pro
102106

103107
[Formatting, Parsing, and Validating Data](https://sdk.openui5.org/topic/07e4b920f5734fd78fdaa236f26236d8.html "Data that is presented on the UI often has to be converted so that is human readable and fits to the locale of the user. On the other hand, data entered by the user has to be parsed and validated to be understood by the data source. For this purpose, you use formatters and data types.")
104108

109+
[Require Modules in XML View and Fragment](https://sdk.openui5.org/topic/b11d853a8e784db6b2d210ef57b0f7d7.html "Modules can be required in XML views and fragments and assigned to aliases which can be used as variables in properties, event handlers, and bindings.")
110+
105111
[API Reference: sap.ui.base.ManagedObject](https://sdk.openui5.org/api/sap.ui.base.ManagedObject)
106112

107113
[API Reference: sap.ui.base.ManagedObject.PropertyBindingInfo](https://sdk.openui5.org/api/sap.ui.base.ManagedObject.PropertyBindingInfo)
@@ -110,4 +116,4 @@ As you can see above, we are using a special binding syntax for the `number` pro
110116

111117
[API Reference: sap.ui.model.type.Currency](https://sdk.openui5.org/api/sap.ui.model.type.Currency)
112118

113-
[Samples: sap.ui.model.type.Currency](https://sdk.openui5.org/entity/sap.ui.model.type.Currency)
119+
[Samples: sap.ui.model.type.Currency](https://sdk.openui5.org/entity/sap.ui.model.type.Currency)
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<mvc:View
22
controllerName="ui5.walkthrough.controller.InvoiceList"
33
xmlns="sap.m"
4+
xmlns:core="sap.ui.core"
45
xmlns:mvc="sap.ui.core.mvc">
56
<List
67
headerText="{i18n>invoiceListTitle}"
@@ -9,18 +10,21 @@
910
items="{invoice>/Invoices}" >
1011
<items>
1112
<ObjectListItem
13+
core:require="{
14+
Currency: 'sap/ui/model/type/Currency'
15+
}"
1216
title="{invoice>Quantity} x {invoice>ProductName}"
1317
number="{
1418
parts: [
15-
'invoice>ExtendedPrice',
19+
'invoice>ExtendedPrice',
1620
'view>/currency'
1721
],
18-
type: 'sap.ui.model.type.Currency',
22+
type: 'Currency',
1923
formatOptions: {
2024
showMeasure: false
2125
}
2226
}"
2327
numberUnit="{view>/currency}"/>
2428
</items>
2529
</List>
26-
</mvc:View>
30+
</mvc:View>

steps/21/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ We add the `numberState` attribute to the `ObjectListItem` control in our invoic
2828
<mvc:View
2929
controllerName="ui5.walkthrough.controller.InvoiceList"
3030
xmlns="sap.m"
31+
xmlns:core="sap.ui.core"
3132
xmlns:mvc="sap.ui.core.mvc">
3233
<List
3334
headerText="{i18n>invoiceListTitle}"
@@ -36,13 +37,16 @@ We add the `numberState` attribute to the `ObjectListItem` control in our invoic
3637
items="{invoice>/Invoices}" >
3738
<items>
3839
<ObjectListItem
40+
core:require="{
41+
Currency: 'sap/ui/model/type/Currency'
42+
}"
3943
title="{invoice>Quantity} x {invoice>ProductName}"
4044
number="{
4145
parts: [
4246
'invoice>ExtendedPrice',
4347
'view>/currency'
4448
],
45-
type: 'sap.ui.model.type.Currency',
49+
type: 'Currency',
4650
formatOptions: {
4751
showMeasure: false
4852
}
@@ -78,4 +82,4 @@ Expressions are limited to a particular set of operations that help formatting t
7882

7983
**Related Information**
8084

81-
[Expression Binding](https://sdk.openui5.org/topic/daf6852a04b44d118963968a1239d2c0.html "Expression binding is an enhancement of the OpenUI5 binding syntax, which allows for providing expressions instead of custom formatter functions.")
85+
[Expression Binding](https://sdk.openui5.org/topic/daf6852a04b44d118963968a1239d2c0.html "Expression binding is an enhancement of the OpenUI5 binding syntax, which allows for providing expressions instead of custom formatter functions.")
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<mvc:View
22
controllerName="ui5.walkthrough.controller.InvoiceList"
33
xmlns="sap.m"
4+
xmlns:core="sap.ui.core"
45
xmlns:mvc="sap.ui.core.mvc">
56
<List
67
headerText="{i18n>invoiceListTitle}"
@@ -9,13 +10,16 @@
910
items="{invoice>/Invoices}" >
1011
<items>
1112
<ObjectListItem
13+
core:require="{
14+
Currency: 'sap/ui/model/type/Currency'
15+
}"
1216
title="{invoice>Quantity} x {invoice>ProductName}"
1317
number="{
1418
parts: [
15-
'invoice>ExtendedPrice',
19+
'invoice>ExtendedPrice',
1620
'view>/currency'
1721
],
18-
type: 'sap.ui.model.type.Currency',
22+
type: 'Currency',
1923
formatOptions: {
2024
showMeasure: false
2125
}
@@ -24,4 +28,4 @@
2428
numberState="{= ${invoice>ExtendedPrice} > 50 ? 'Error' : 'Success' }"/>
2529
</items>
2630
</List>
27-
</mvc:View>
31+
</mvc:View>

steps/22/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,16 @@ We add a status using the `firstStatus` aggregation to our `ObjectListItem` that
9797
items="{invoice>/Invoices}" >
9898
<items>
9999
<ObjectListItem
100+
core:require="{
101+
Currency: 'sap/ui/model/type/Currency'
102+
}"
100103
title="{invoice>Quantity} x {invoice>ProductName}"
101104
number="{
102105
parts: [
103106
'invoice>ExtendedPrice',
104107
'view>/currency'
105108
],
106-
type: 'sap.ui.model.type.Currency',
109+
type: 'Currency',
107110
formatOptions: {
108111
showMeasure: false
109112
}

steps/22/webapp/view/InvoiceList.view.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@
1010
items="{invoice>/Invoices}" >
1111
<items>
1212
<ObjectListItem
13+
core:require="{
14+
Currency: 'sap/ui/model/type/Currency'
15+
}"
1316
title="{invoice>Quantity} x {invoice>ProductName}"
1417
number="{
1518
parts: [
1619
'invoice>ExtendedPrice',
1720
'view>/currency'
1821
],
19-
type: 'sap.ui.model.type.Currency',
22+
type: 'Currency',
2023
formatOptions: {
2124
showMeasure: false
2225
}

steps/23/webapp/view/InvoiceList.view.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@
1717
</headerToolbar>
1818
<items>
1919
<ObjectListItem
20+
core:require="{
21+
Currency: 'sap/ui/model/type/Currency'
22+
}"
2023
title="{invoice>Quantity} x {invoice>ProductName}"
2124
number="{
2225
parts: [
2326
'invoice>ExtendedPrice',
2427
'view>/currency'
2528
],
26-
type: 'sap.ui.model.type.Currency',
29+
type: 'Currency',
2730
formatOptions: {
2831
showMeasure: false
2932
}

steps/24/webapp/view/InvoiceList.view.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@
2323
</headerToolbar>
2424
<items>
2525
<ObjectListItem
26+
core:require="{
27+
Currency: 'sap/ui/model/type/Currency'
28+
}"
2629
title="{invoice>Quantity} x {invoice>ProductName}"
2730
number="{
2831
parts: [
2932
'invoice>ExtendedPrice',
3033
'view>/currency'
3134
],
32-
type: 'sap.ui.model.type.Currency',
35+
type: 'Currency',
3336
formatOptions: {
3437
showMeasure: false
3538
}

steps/25/webapp/view/InvoiceList.view.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@
2323
</headerToolbar>
2424
<items>
2525
<ObjectListItem
26+
core:require="{
27+
Currency: 'sap/ui/model/type/Currency'
28+
}"
2629
title="{invoice>Quantity} x {invoice>ProductName}"
2730
number="{
2831
parts: [
2932
'invoice>ExtendedPrice',
3033
'view>/currency'
3134
],
32-
type: 'sap.ui.model.type.Currency',
35+
type: 'Currency',
3336
formatOptions: {
3437
showMeasure: false
3538
}

steps/26/webapp/view/InvoiceList.view.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@
2323
</headerToolbar>
2424
<items>
2525
<ObjectListItem
26+
core:require="{
27+
Currency: 'sap/ui/model/type/Currency'
28+
}"
2629
title="{invoice>Quantity} x {invoice>ProductName}"
2730
number="{
2831
parts: [
2932
'invoice>ExtendedPrice',
3033
'view>/currency'
3134
],
32-
type: 'sap.ui.model.type.Currency',
35+
type: 'Currency',
3336
formatOptions: {
3437
showMeasure: false
3538
}

steps/27/webapp/view/InvoiceList.view.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@
2323
</headerToolbar>
2424
<items>
2525
<ObjectListItem
26+
core:require="{
27+
Currency: 'sap/ui/model/type/Currency'
28+
}"
2629
title="{invoice>Quantity} x {invoice>ProductName}"
2730
number="{
2831
parts: [
2932
'invoice>ExtendedPrice',
3033
'view>/currency'
3134
],
32-
type: 'sap.ui.model.type.Currency',
35+
type: 'Currency',
3336
formatOptions: {
3437
showMeasure: false
3538
}

steps/28/webapp/view/InvoiceList.view.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@
2323
</headerToolbar>
2424
<items>
2525
<ObjectListItem
26+
core:require="{
27+
Currency: 'sap/ui/model/type/Currency'
28+
}"
2629
title="{invoice>Quantity} x {invoice>ProductName}"
2730
number="{
2831
parts: [
2932
'invoice>ExtendedPrice',
3033
'view>/currency'
3134
],
32-
type: 'sap.ui.model.type.Currency',
35+
type: 'Currency',
3336
formatOptions: {
3437
showMeasure: false
3538
}

steps/29/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ We introduced a typo in the binding of the number attribute to simulate a freque
3030
<mvc:View
3131
controllerName="ui5.walkthrough.controller.InvoiceList"
3232
xmlns="sap.m"
33+
xmlns:core="sap.ui.core"
3334
xmlns:mvc="sap.ui.core.mvc">
3435
<List
3536
id="invoiceList"
@@ -51,13 +52,16 @@ We introduced a typo in the binding of the number attribute to simulate a freque
5152
</headerToolbar>
5253
<items>
5354
<ObjectListItem
55+
core:require="{
56+
Currency: 'sap/ui/model/type/Currency'
57+
}"
5458
title="{invoice>Quantity} x {invoice>ProductName}"
5559
number="{
5660
parts: [
5761
'invoice>ExTendedPrice',
5862
'view>/currency'
5963
],
60-
type: 'sap.ui.model.type.Currency',
64+
type: 'Currency',
6165
formatOptions: {
6266
showMeasure: false
6367
}
@@ -127,4 +131,4 @@ If you're stuck and need help for some development task, you can also post a que
127131

128132
[Technical Information Dialog](https://sdk.openui5.org/topic/616a3ef07f554e20a3adf749c11f64e9.html#loio616a3ef07f554e20a3adf749c11f64e9 "The Technical Information dialog shows details of the OpenUI5 version currently being used in an app built with OpenUI5. You can use the Technical Information dialog to enable debug resources and open additional support tools to debug your app.")
129133

130-
[UI5 Inspector](https://sdk.openui5.org/topic/b24e72443eb34d0fb7bf6940f2d697eb.html)
134+
[UI5 Inspector](https://sdk.openui5.org/topic/b24e72443eb34d0fb7bf6940f2d697eb.html)

steps/29/webapp/view/InvoiceList.view.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@
2323
</headerToolbar>
2424
<items>
2525
<ObjectListItem
26+
core:require="{
27+
Currency: 'sap/ui/model/type/Currency'
28+
}"
2629
title="{invoice>Quantity} x {invoice>ProductName}"
2730
number="{
2831
parts: [
2932
'invoice>ExtendedPrice',
3033
'view>/currency'
3134
],
32-
type: 'sap.ui.model.type.Currency',
35+
type: 'Currency',
3336
formatOptions: {
3437
showMeasure: false
3538
}

steps/30/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,17 +258,21 @@ In the invoice list view we finally add the press event to the list item we just
258258
<mvc:View
259259
controllerName="ui5.walkthrough.controller.InvoiceList"
260260
xmlns="sap.m"
261+
xmlns:core="sap.ui.core"
261262
xmlns:mvc="sap.ui.core.mvc">
262263
...
263264
<items>
264265
<ObjectListItem
266+
core:require="{
267+
Currency: 'sap/ui/model/type/Currency'
268+
}"
265269
title="{invoice>Quantity} x {invoice>ProductName}"
266270
number="{
267271
parts: [
268272
'invoice>ExtendedPrice',
269273
'view>/currency'
270274
],
271-
type: 'sap.ui.model.type.Currency',
275+
type: 'Currency',
272276
formatOptions: {
273277
showMeasure: false
274278
}

steps/30/webapp/view/InvoiceList.view.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@
2323
</headerToolbar>
2424
<items>
2525
<ObjectListItem
26+
core:require="{
27+
Currency: 'sap/ui/model/type/Currency'
28+
}"
2629
title="{invoice>Quantity} x {invoice>ProductName}"
2730
number="{
2831
parts: [
2932
'invoice>ExtendedPrice',
3033
'view>/currency'
3134
],
32-
type: 'sap.ui.model.type.Currency',
35+
type: 'Currency',
3336
formatOptions: {
3437
showMeasure: false
3538
}

0 commit comments

Comments
 (0)