Show TOC

Step 15: Reuse an Existing RouteLocate this document in the navigation structure

The Employees table displays employee data. However, the resumes of the employees are not accessible from this view yet. We could create a new route and a new view to visualize the resume again, but we could also simply reuse an existing route to cross-link the resume of a certain employee. In this step, we will add a feature that allows users to directly navigate to the resume of a certain employee. We will reuse the Resume page that we have created in an earlier step. This example illustrates that there can be multiple navigation paths that direct to the same page.

Figure 1: Navigation to an existing route from a table item

You can view and download all files in the Explored app in the Demo Kit under Routing and Navigation - Step 15.

	<Table id="employeesTable"
			<ColumnListItem type="Active">

In the EmployeeOverviewContent view we register an event handler for the itemPress event and set the type attribute of the ColumnListItem to Active so that we can choose an item and trigger the navigation.

], function (BaseController, Filter, FilterOperator, Sorter) {
	"use strict";
	return BaseController.extend("sap.ui.demo.nav.controller.employee.overview.EmployeeOverviewContent", {
		_syncViewSettingsDialogSorter : function (sSortField, bSortDescending) {
			// the possible keys are: "EmployeeID" | "FirstName" | "LastName"
			// Note: no input validation is implemented here
		onItemPressed : function (oEvent) {
			var oItem, oCtx, oRouter;
			oItem = oEvent.getParameter("listItem");
			oCtx = oItem.getBindingContext();
				employeeId : oCtx.getProperty("EmployeeID"),
				query : {
					tab : "Info"

Next we add the itemPress handler onItemPressed to the EmployeeOverviewContent controller. It reads from the binding context which item has been chosen and navigates to the employeeResume route. We have already added this route and the corresponding target in a previous step and can now reuse it. From now on it is possible to navigate to the employeeResume route from our employee table as well as from the employee detail page created in an earlier step (the route name is employee).