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
@@ -84,8 +83,6 @@ We configure the CSS file to our app descriptor: In the `resources` section of t
84
83
}
85
84
```
86
85
87
-
***
88
-
89
86
### webapp/view/App.view.xml
90
87
91
88
The app control is configured with our custom namespace class `myAppDemoWT`. This class has no styling rules set and is used in the definition of the CSS rules to define CSS selectors that are only valid for this app.
@@ -130,7 +127,7 @@ To highlight the output text, we replace the text control by a `FormattedText` c
130
127
</Shell>
131
128
</mvc:View>
132
129
```
133
-
130
+
134
131
The actual color now depends on the selected theme which ensures that the color always fits to the theme and is semantically clear. For a complete list of the available CSS class names, see [CSS Classes for Theme Parameters](https://sdk.openui5.org/topic/ea08f53503da42c19afd342f4b0c9ec7.html).
In folder `webapp/controller` we create a new `HelloPanel.controller.ts` file and move the method `onShowHello` of the app controller to it, so we get a reusable asset.
37
+
In folder `webapp/controller` we create a new `HelloPanel.controller.?s` file and move the method `onShowHello` of the app controller to it, so we get a reusable asset.
We have now moved everything out of the app view and controller. The app controller remains an empty stub for now, we will use it later to add more functionality.
Copy file name to clipboardExpand all lines: steps/16/README.md
+30-6Lines changed: 30 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,14 +51,12 @@ We add a new XML file to declaratively define our dialog in a fragment. The frag
51
51
title="Hello {/recipient/name}"/>
52
52
</core:FragmentDefinition>
53
53
```
54
-
54
+
55
55
The syntax is similar to a view, but since fragments do not have a controller this attribute is missing. Also, the fragment does not have any footprint in the DOM tree of the app, and there is no control instance of the fragment itself (only the contained controls). It is simply a container for a set of reuse controls.
56
56
57
-
***
57
+
### webapp/controller/HelloPanel.controller.?s
58
58
59
-
### webapp/controller/HelloPanel.controller.ts
60
-
61
-
In the HelloPanel controller, we define a new event handler function `onOpenDialog` which calls the dialog in the HelloDialog fragment when triggered. To do so we need to import the `sap.m.Dialog` module.
59
+
In the HelloPanel controller, we define a new event handler function `onOpenDialog` which calls the dialog in the HelloDialog fragment when triggered. To do so we need the `sap.m.Dialog` module.
62
60
63
61
Using async/await, we handle the opening of the dialog asynchronously whenever the event is triggered.
> To reuse the dialog opening and closing functionality in other controllers, you might create a new file `ui5.walkthrough.controller.controller.BaseController`, which extends `sap.ui.core.mvc.Controller`, and put all your dialog-related coding into this controller. Now, all the other controllers can extend from `ui5.walkthrough.controller.BaseController` instead of `sap.ui.core.mvc.Controller`.
95
119
@@ -142,7 +166,7 @@ We add a new button to the view to open the dialog and assign an unique `id`to i
142
166
</Panel>
143
167
</mvc:View>
144
168
```
145
-
169
+
146
170
You will need the id of the button control `id="helloDialogButton"` in [Step 28: Integration Test with OPA](../28/README.md).
147
171
148
172
It is a good practice to set a unique ID like `helloWorldButton` to key controls of your app so that they can be identified easily. If the attribute `id` is not specified, the OpenUI5 runtime generates unique but changing ID like `\_\_button23` for the control. Inspect the DOM elements of your app in the browser to see the difference.
Copy file name to clipboardExpand all lines: steps/17/README.md
+43-12Lines changed: 43 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ You can download the solution for this step here: [📥 Download step 17](https:
30
30
</details>
31
31
***
32
32
33
-
### webapp/controller/HelloPanel.controller.ts
33
+
### webapp/controller/HelloPanel.controller.?s
34
34
35
35
We add an event handler function into the HelloPanel controller file that closes the dialog when triggered. To get the dialog instance we use the `byId` function and then call the `close` function of the dialog.
36
36
@@ -46,23 +46,56 @@ import Dialog from "sap/m/Dialog";
@@ -80,8 +113,6 @@ openDialogButtonText=Say Hello With Dialog
80
113
dialogCloseButtonText=Ok
81
114
```
82
115
83
-
***
84
-
85
116
### webapp/view/HelloDialog.fragment.xml
86
117
87
118
In the fragment definition, we add a button to the `beginButton` aggregation of the dialog and refer the press handler to the event handler we just defined in the controller of the panel’s content view.
@@ -101,7 +132,7 @@ In the fragment definition, we add a button to the `beginButton` aggregation of
101
132
</Dialog>
102
133
</core:FragmentDefinition>
103
134
```
104
-
135
+
105
136
By using the `loadFragment` function to create the fragment content in the controller of the panel’s content view, the method will be invoked there when the button is pressed. The dialog has an aggregation named `beginButton` as well as `endButton`. Placing buttons in both of these aggregations makes sure that the `beginButton` is placed before the `endButton` on the UI. What `before` means, however, depends on the text direction of the current language. We therefore use the terms `begin` and `end` as a synonym to “left” and “right". In languages with left-to-right direction, the `beginButton` will be rendered left, the `endButton` on the right side of the dialog footer; in right-to-left mode for specific languages the order is switched.
Copy file name to clipboardExpand all lines: steps/19/README.md
+4-14Lines changed: 4 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,6 @@
1
1
## Step 19: Aggregation Binding
2
2
3
3
Now that we have established a good structure for our app, it's time to add some more functionality. We start exploring more features of data binding by adding some invoice data in JSON format that we display in a list below the panel.
4
-
5
4
6
5
7
6
***
@@ -81,16 +80,13 @@ We create a new folder `model` in our app project and place the new `localInvoic
81
80
]
82
81
}
83
82
```
84
-
83
+
85
84
The `localinvoices` file simply contains five invoices in a JSON format that we can use to bind controls against them in the app. JSON is a very lightweight format for storing data and can be directly used as a data source for OpenUI5 applications.
86
85
87
-
***
88
-
89
86
### webapp/manifest.json
90
87
91
88
We add a new named model `invoice` to the `sap.ui5` section of the descriptor. This time we want a JSONModel, so we set the type to `sap.ui.model.json.JSONModel`. The `uri` key is the path to our data relative to the component.
92
89
93
-
94
90
```json
95
91
{
96
92
...
@@ -122,11 +118,9 @@ We add a new named model `invoice` to the `sap.ui5` section of the descriptor. T
122
118
}
123
119
}
124
120
```
125
-
121
+
126
122
With this little configuration our component will automatically instantiate a new `JSONModel` which loads the invoice data from the `localInvoices.json` file. Finally, the instantiated `JSONModel` is put onto the component as a named model invoice. The named model is then visible throughout our app.
127
123
128
-
***
129
-
130
124
### webapp/i18n/i18n.properties
131
125
132
126
In the text bundle we create a new text for a Invoice List title we will need in the view we are about to create.
@@ -167,11 +161,9 @@ In the `items` aggregation, we define the template for the list that will be aut
167
161
</List>
168
162
</mvc:View>
169
163
```
170
-
164
+
171
165
The binding in the list item works, because we have bound the `items` aggregation via `items={invoice>/Invoices}` to the invoices.
172
166
173
-
***
174
-
175
167
### webapp/view/App.view.xml
176
168
177
169
In the app view we add a second view and assign it to our newly created InvoiceList view to display our invoices below the panel.
@@ -227,6 +219,4 @@ In the app view we add a second view and assign it to our newly created InvoiceL
We want to display in our list view the price in Euro, and typically the currency is part of our data model on the back end. In our case this is not the case, so we need to define it directly in the app. We therefore create a controller for the invoice list and define a view model for the currency code for Euro. It is a simple JSON model with just one key `currency` and the value `EUR`.
35
+
We want to display in our list view the price in Euro. Since currency information isn't available in our backend data model, we'll handle the currency formatting within the application.
36
+
37
+
We'll create a controller for the InvoiceList view and use a JSON model (`sap/ui/model/json/JSONModel`) to store the currency code. This model will contain a single property, `currency: "EUR"`, which will be used for formatting the prices in the view.
0 commit comments