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, SAPUI5 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
You can view and download all files at Walkthrough - Step 29.
<mvc:View
controllerName="ui5.walkthrough.controller.InvoiceList"
xmlns="sap.m"
xmlns:core="sap.ui.core"
xmlns:mvc="sap.ui.core.mvc">
<List
id="invoiceList"
headerText="{i18n>invoiceListTitle}"
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
core:require="{
Formatter: 'ui5/walkthrough/model/formatter'
}"
text="{
path: 'invoice>Status',
formatter: 'Formatter.statusText.bind($controller)'
}"/>
</firstStatus>
</ObjectListItem>
</items>
</List>
</mvc:View>
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'
. 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 SAPUI5 support diagnostics tool and check the app.
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 SAPUI5 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.
When debugging UI5 applications that use built resources, the SAPUI5 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 SAPUI5 artifacts.
Technical information dialog
For a more detailed explanation of the SAPUI5 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 SAPUI5-related forums, for example in the SAP Community or on Stack Overflow.
- As per SAPUI5 convention uncompressed source files end with
*-dbg.js
Related Information