Skip to content

Commit 7fe1738

Browse files
committed
Added everything for Step 6: Resource Models
1 parent cb37402 commit 7fe1738

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

webapp/controller/Home.controller.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ sap.ui.define(
22
[
33
"com/mrb/UI5-Data-Binding/controller/BaseController",
44
"sap/ui/model/json/JSONModel",
5-
"sap/ui/model/BindingMode",
5+
"sap/ui/model/resource/ResourceModel"
66
],
7-
function (BaseController, JSONModel, BindingMode) {
7+
function (BaseController, JSONModel, ResourceModel) {
88
"use strict";
99

1010
return BaseController.extend("com.mrb.UI5-Data-Binding.controller.Home", {
@@ -17,11 +17,17 @@ sap.ui.define(
1717
panelHeaderText: "Data Binding Basics",
1818
});
1919

20-
oModel.setDefaultBindingMode(BindingMode.OneWay);
20+
// Create a resource bundle for language specific texts
21+
// nowadays those are being declared via manifest.json
22+
var oResourceModel = new ResourceModel({
23+
bundleName: "com.mrb.UI5-Data-Binding.i18n.i18n_example",
24+
});
25+
2126
//Set model globally for all views/controls (dirty) "sap.ui.getCore().setModel(oModel);""
2227
//the go-to way for global definition would be to define the model within the manifest.json-file
2328
//and retrieve it via "this.getOwnerComponent().getModel();"
2429
this.getView().setModel(oModel);
30+
this.getView().setModel(oResourceModel, "i18n_example")
2531
},
2632
});
2733
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Field labels
2+
firstName=First Name
3+
lastName=Last Name
4+
enabled=Enabled
5+
6+
# Screen titles
7+
panelHeaderText=Data Binding Basics

webapp/view/Home.view.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
xmlns="sap.m"
33
xmlns:mvc="sap.ui.core.mvc">
44
<Page titleAlignment="Center" title="{i18n>title}">
5-
<Panel headerText="{/panelHeaderText}" class="sapUiResponsiveMargin" width="auto">
5+
<Panel headerText="{i18n_example>panelHeaderText}" class="sapUiResponsiveMargin" width="auto">
66
<content>
7-
<Label text="First Name" class="sapUiSmallMargin" />
7+
<Label text="{i18n_example>firstName}" class="sapUiSmallMargin" />
88
<Input value="{/firstName}" valueLiveUpdate="true" width="200px" enabled="{/enabled}" />
9-
<Label text="Last Name" class="sapUiSmallMargin" />
9+
<Label text="{i18n_example>lastName}" class="sapUiSmallMargin" />
1010
<Input value="{/lastName}" valueLiveUpdate="true" width="200px" enabled="{/enabled}" />
11-
<CheckBox selected="{/enabled}" text="Enabled" />
11+
<CheckBox selected="{/enabled}" text="{i18n_example>enabled}" />
1212
</content>
1313
</Panel>
1414
</Page>

0 commit comments

Comments
 (0)