Skip to content

Commit 61af8c1

Browse files
committed
Step 6: Navigate to Routes with Hard-Coded Patterns
1 parent 574db78 commit 61af8c1

8 files changed

+63
-19
lines changed

webapp/controller/Home.controller.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ sap.ui.define([
1212
*/
1313
//display the "notFound" target without changing the hash
1414
this.getRouter().getTargets().display("notFound", {
15-
fromTarget: "home"
16-
});
17-
15+
fromTarget: "home"
16+
});
17+
},
18+
onNavToEmployees: function () {
19+
this.getRouter().navTo("employeeList");
1820
}
1921
});
2022
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
sap.ui.define([
2+
"com/mrb/UI5-Navigation-and-Routing/controller/BaseController"
3+
], function (BaseController) {
4+
"use strict";
5+
return BaseController.extend("com.mrb.UI5-Navigation-and-Routing.controller.employee.EmployeeList", {});
6+
});

webapp/i18n/i18n.properties

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ homePageTitle=Home
66
NotFound=Not Found
77
NotFound.text=Sorry, but the requested resource is not available.
88
NotFound.description=Please check the URL and try again.
9-
DisplayNotFound=Display Not Found
9+
DisplayNotFound=Display Not Found
10+
ShowEmployeeList=Show Employee List
11+
EmployeeList=Employee List
12+
ListOfAllEmployees=List of all employees

webapp/i18n/i18n_en.properties

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ homePageTitle=Home
66
NotFound=Not Found
77
NotFound.text=Sorry, but the requested resource is not available.
88
NotFound.description=Please check the URL and try again.
9-
DisplayNotFound=Display Not Found
9+
DisplayNotFound=Display Not Found
10+
ShowEmployeeList=Show Employee List
11+
EmployeeList=Employee List
12+
ListOfAllEmployees=List of all employees

webapp/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
data-sap-ui-oninit="module:com/mrb/UI5-Navigation-and-Routing/initMockServer"
1818
data-sap-ui-compatVersion="edge"
1919
data-sap-ui-async="true"
20+
data-sap-ui-xx-bindingSyntax="complex"
2021
data-sap-ui-frameOptions="trusted">
2122
</script>
2223
</head>

webapp/manifest.json

+29-14
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
"type": "OData",
1616
"settings": {
1717
"odataVersion": "2.0",
18-
"localUri" : "localService/metadata.xml"
18+
"localUri": "localService/metadata.xml"
1919
}
2020
}
2121
}
2222
},
23-
2423
"sap.ui": {
2524
"technology": "UI5",
2625
"icons": {
@@ -37,7 +36,6 @@
3736
"phone": true
3837
}
3938
},
40-
4139
"sap.ui5": {
4240
"rootView": {
4341
"viewName": "com.mrb.UI5-Navigation-and-Routing.view.App",
@@ -69,9 +67,11 @@
6967
}
7068
},
7169
"resources": {
72-
"css": [{
73-
"uri": "css/style.css"
74-
}]
70+
"css": [
71+
{
72+
"uri": "css/style.css"
73+
}
74+
]
7575
},
7676
"routing": {
7777
"config": {
@@ -80,17 +80,26 @@
8080
"viewPath": "com.mrb.UI5-Navigation-and-Routing.view",
8181
"controlId": "app",
8282
"controlAggregation": "pages",
83-
"transition": "slide",
83+
"transition": "slide",
8484
"bypassed": {
8585
"target": "notFound"
86-
},
86+
},
8787
"async": true
8888
},
89-
"routes": [{
90-
"name": "appHome",
91-
"pattern": "",
92-
"target": ["home"]
93-
}],
89+
"routes": [
90+
{
91+
"name": "appHome",
92+
"pattern": "",
93+
"target": [
94+
"home"
95+
]
96+
},
97+
{
98+
"name": "employeeList",
99+
"pattern": "employees",
100+
"target": "employees"
101+
}
102+
],
94103
"targets": {
95104
"home": {
96105
"viewType": "XML",
@@ -103,8 +112,14 @@
103112
"viewId": "notFound",
104113
"viewName": "NotFound",
105114
"transition": "show"
115+
},
116+
"employees": {
117+
"viewId": "employeeList",
118+
"viewPath": "com.mrb.UI5-Navigation-and-Routing.view.employee",
119+
"viewName": "EmployeeList",
120+
"viewLevel": 2
106121
}
107122
}
108123
}
109124
}
110-
}
125+
}

webapp/view/Home.view.xml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<Page title="{i18n>homePageTitle}" class="sapUiResponsiveContentPadding">
66
<content>
77
<Button id="displayNotFoundBtn" text="{i18n>DisplayNotFound}" press=".onDisplayNotFound" class="sapUiTinyMarginEnd"/>
8+
<Button id="employeeListBtn" text="{i18n>ShowEmployeeList}" press=".onNavToEmployees" class="sapUiTinyMarginEnd"/>
89
</content>
910
</Page>
1011
</mvc:View>
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<mvc:View controllerName="com.mrb.UI5-Navigation-and-Routing.controller.employee.EmployeeList"
2+
xmlns="sap.m"
3+
xmlns:mvc="sap.ui.core.mvc">
4+
<Page id="employeeListPage" title="{i18n>EmployeeList}" showNavButton="true" navButtonPress=".onNavBack" class="sapUiResponsiveContentPadding">
5+
<content>
6+
<List id="employeeList" headerText="{i18n>ListOfAllEmployees}" items="{/Employees}">
7+
<items>
8+
<StandardListItem title="{FirstName} {LastName}" iconDensityAware="false" iconInset="false"/>
9+
</items>
10+
</List>
11+
</content>
12+
</Page>
13+
</mvc:View>

0 commit comments

Comments
 (0)