Skip to content

Commit

Permalink
Step 6: Navigate to Routes with Hard-Coded Patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
wridgeu committed Mar 21, 2020
1 parent 574db78 commit 61af8c1
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 19 deletions.
8 changes: 5 additions & 3 deletions webapp/controller/Home.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ sap.ui.define([
*/
//display the "notFound" target without changing the hash
this.getRouter().getTargets().display("notFound", {
fromTarget: "home"
});

fromTarget: "home"
});
},
onNavToEmployees: function () {
this.getRouter().navTo("employeeList");
}
});
});
6 changes: 6 additions & 0 deletions webapp/controller/employee/EmployeeList.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
sap.ui.define([
"com/mrb/UI5-Navigation-and-Routing/controller/BaseController"
], function (BaseController) {
"use strict";
return BaseController.extend("com.mrb.UI5-Navigation-and-Routing.controller.employee.EmployeeList", {});
});
5 changes: 4 additions & 1 deletion webapp/i18n/i18n.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ homePageTitle=Home
NotFound=Not Found
NotFound.text=Sorry, but the requested resource is not available.
NotFound.description=Please check the URL and try again.
DisplayNotFound=Display Not Found
DisplayNotFound=Display Not Found
ShowEmployeeList=Show Employee List
EmployeeList=Employee List
ListOfAllEmployees=List of all employees
5 changes: 4 additions & 1 deletion webapp/i18n/i18n_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ homePageTitle=Home
NotFound=Not Found
NotFound.text=Sorry, but the requested resource is not available.
NotFound.description=Please check the URL and try again.
DisplayNotFound=Display Not Found
DisplayNotFound=Display Not Found
ShowEmployeeList=Show Employee List
EmployeeList=Employee List
ListOfAllEmployees=List of all employees
1 change: 1 addition & 0 deletions webapp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
data-sap-ui-oninit="module:com/mrb/UI5-Navigation-and-Routing/initMockServer"
data-sap-ui-compatVersion="edge"
data-sap-ui-async="true"
data-sap-ui-xx-bindingSyntax="complex"
data-sap-ui-frameOptions="trusted">
</script>
</head>
Expand Down
43 changes: 29 additions & 14 deletions webapp/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
"type": "OData",
"settings": {
"odataVersion": "2.0",
"localUri" : "localService/metadata.xml"
"localUri": "localService/metadata.xml"
}
}
}
},

"sap.ui": {
"technology": "UI5",
"icons": {
Expand All @@ -37,7 +36,6 @@
"phone": true
}
},

"sap.ui5": {
"rootView": {
"viewName": "com.mrb.UI5-Navigation-and-Routing.view.App",
Expand Down Expand Up @@ -69,9 +67,11 @@
}
},
"resources": {
"css": [{
"uri": "css/style.css"
}]
"css": [
{
"uri": "css/style.css"
}
]
},
"routing": {
"config": {
Expand All @@ -80,17 +80,26 @@
"viewPath": "com.mrb.UI5-Navigation-and-Routing.view",
"controlId": "app",
"controlAggregation": "pages",
"transition": "slide",
"transition": "slide",
"bypassed": {
"target": "notFound"
},
},
"async": true
},
"routes": [{
"name": "appHome",
"pattern": "",
"target": ["home"]
}],
"routes": [
{
"name": "appHome",
"pattern": "",
"target": [
"home"
]
},
{
"name": "employeeList",
"pattern": "employees",
"target": "employees"
}
],
"targets": {
"home": {
"viewType": "XML",
Expand All @@ -103,8 +112,14 @@
"viewId": "notFound",
"viewName": "NotFound",
"transition": "show"
},
"employees": {
"viewId": "employeeList",
"viewPath": "com.mrb.UI5-Navigation-and-Routing.view.employee",
"viewName": "EmployeeList",
"viewLevel": 2
}
}
}
}
}
}
1 change: 1 addition & 0 deletions webapp/view/Home.view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<Page title="{i18n>homePageTitle}" class="sapUiResponsiveContentPadding">
<content>
<Button id="displayNotFoundBtn" text="{i18n>DisplayNotFound}" press=".onDisplayNotFound" class="sapUiTinyMarginEnd"/>
<Button id="employeeListBtn" text="{i18n>ShowEmployeeList}" press=".onNavToEmployees" class="sapUiTinyMarginEnd"/>
</content>
</Page>
</mvc:View>
13 changes: 13 additions & 0 deletions webapp/view/employee/EmployeeList.view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<mvc:View controllerName="com.mrb.UI5-Navigation-and-Routing.controller.employee.EmployeeList"
xmlns="sap.m"
xmlns:mvc="sap.ui.core.mvc">
<Page id="employeeListPage" title="{i18n>EmployeeList}" showNavButton="true" navButtonPress=".onNavBack" class="sapUiResponsiveContentPadding">
<content>
<List id="employeeList" headerText="{i18n>ListOfAllEmployees}" items="{/Employees}">
<items>
<StandardListItem title="{FirstName} {LastName}" iconDensityAware="false" iconInset="false"/>
</items>
</List>
</content>
</Page>
</mvc:View>

0 comments on commit 61af8c1

Please sign in to comment.