In SAPUI5, each view is represented by a dedicated file in the view folder.
Add a new view with a right-click on the view folder and select New File. Name this file List.view.xml.
newFile
The name already suggests that this view will contain a list of products. Add the following file content that defines the views and the list. Note the list already uses data binding to show the product entities as list items.
Repeat step 1 to create another view with the name Detail.view.xml. We will use this view to display details of a given product.
Insert the following content in this new file. In contrast to the list, it uses a relative binding, e.g. the binding path doesn’t start with / like absolute paths do.
Hint: You don’t need to rely on the code editor to edit the views. Right-click on any view and select Open With… > Layout Editor to access the WYSIWYG layout editor:
detailView
Step 2Add new targets and routes
+
In this step we’ll define so-called routes and targets, which are needed for the automated navigation we want to use. Each route defines a (URL) pattern and the target it points to, and each target specifies the view it refers to.
Change the pattern for the first route (“RouteView1”) from :?query: to RouteView1 (line 16 of the below snippet) in the webapp/manifest.json file, so that we can define a new default route.
Add the new targets and routes to the webapp/manifest.json file.
This is the crucial step of this tutorial that ties everything together. Each view specifies its controller with the controllerName property in the first line. Controllers contain the business logic of web apps, bind models to views, and use the router to navigate between views.
You may see a prompt to enable ESLint extension, select Do Not Allow to proceed as it is not relevant for this tutorial.
Right-click on the controller folder and select New File to create a new List.controller.js for the list view. The controller defines one method that is the event listener for the press-item event of the product list. It will trigger the navigation to the second view and attach the product ID of the pressed item.
Choose New File one more time to create a Detail.controller.js file, which corresponds to the detail view. This control contains methods to handle the inbound navigation, to bind the selected product to the view, and to handle the outbound navigation to get back to the list. Insert the following code into the file.
Share feedback on this tutorial or join the conversation in SAP Community.
Submit detailed feedbackDiscuss in Community
Steps
Step 1 of 4
1. Add two new views2. Add new targets and routes3. Add two new controllers4. Test it
Joule
AI Notice
Joule is an AI assistant. Generative AI may produce inaccurate, incomplete, or biased information. Always verify important details before acting on them.
Conversations are sent to SAP-hosted large language models for processing. Do not include personal data, credentials, or confidential information in your messages.
Joule's responses are based on the SAP tutorial catalog and may not reflect the latest product changes. For authoritative guidance, consult the linked tutorials and official SAP documentation.