Even though we have added a basic test coverage in the previous steps, it seems like we accidentally broke our app, because it does not display prices to our invoices anymore. We need to debug the issue and fix it before someone finds out.
Luckily, OpenUI5 provides a couple of debugging tools that we can use within the app to check the application logic and the developer tools of modern browsers are also quite good. We will now check for the root cause.
The diagnostics window
The code in this step remains unchanged, except for the addition and subsequent removal of a bug using troubleshooting tools. As a result, there is no live preview or download available for this step.
We introduced a typo in the binding of the number attribute to simulate a frequent error; instead of using 'invoice>ExtendedPrice'
we use 'invoice>ExTendedPrice'
.
<mvc:View
controllerName="ui5.walkthrough.controller.InvoiceList"
xmlns="sap.m"
xmlns:mvc="sap.ui.core.mvc">
<List
id="invoiceList"
class="sapUiResponsiveMargin"
width="auto"
items="{
path : 'invoice>/Invoices',
sorter : {
path : 'ShipperName',
group : true
}
}" >
<headerToolbar>
<Toolbar>
<Title text="{i18n>invoiceListTitle}"/>
<ToolbarSpacer/>
<SearchField width="50%" search=".onFilterInvoices"/>
</Toolbar>
</headerToolbar>
<items>
<ObjectListItem
title="{invoice>Quantity} x {invoice>ProductName}"
number="{
parts: [
'invoice>ExTendedPrice',
'view>/currency'
],
type: 'sap.ui.model.type.Currency',
formatOptions: {
showMeasure: false
}
}"
numberUnit="{view>/currency}"
numberState="{= ${invoice>ExtendedPrice} > 50 ? 'Error' : 'Success' }">
<firstStatus>
<ObjectStatus text="{
path: 'invoice>Status',
formatter: '.formatter.statusText'
}"/>
</firstStatus>
</ObjectListItem>
</items>
</List>
</mvc:View>
Now we call the app and notice that the price is actually missing. By entering the shortcut [Ctrl] + [Shift] + [Alt] /[Option] + [S] we open the OpenUI5 support diagnostics tool and check the app.
📝 Note:
If you use the Google Chrome browser, you can install the UI5 Inspector plugin. With this plugin, you can easily debug your SAPUI5- or OpenUI5-based apps. For more information, see UI5 Inspector.
Besides technical information about the app and a trace that is similar to the developer tools console of the browser, there is a really handy tool for checking such errors in this dialog. Open the tab Control Tree by clicking on the expand symbol on the right.
A hierarchical tree of OpenUI5 controls is shown on the left and the properties of the selected control are displayed on the right. If we now select the first ObjectListItem
control of the tree and go to the Binding Infos tab on the right, we can actually see that the binding path of the number attribute is marked as invalid. We can now correct the error in the view and the price should appear in the list of invoices again.
Sometimes errors are not as easy to spot and you actually need to debug the JavaScript code with the tools of the browser.
📝 Note:
When debugging UI5 applications that use built resources, the OpenUI5 files are minified, which means that variable names are shortened and comments are removed.This makes debugging harder, because the code is a lot less readable. You can load the debug sources by adding the URL parameter
sap-ui-debug=true
or by pressing [Ctrl] + [Shift] + [Alt] /[Option] + [P] and selecting Use Debug Sources in the dialog box that is displayed. After reloading the page, you can see in the Network tab of the browser’s developer tools that now a lot of files are loaded that have a–dbg
suffix. These are the source code files that include comments and the uncompressed code of the app and the OpenUI5 artifacts.
Technical information dialog
For a more detailed explanation of the OpenUI5 support tools, go through the Troubleshooting Tutorial tutorial.
If you're stuck and need help for some development task, you can also post a question in the OpenUI5-related forums, for example in the SAP Community or on Stack Overflow.
- As per OpenUI5 convention uncompressed source files end with
*-dbg.js
Next: Step 30: Routing and Navigation
Previous: Step 28: Integration Test with OPA
Related Information