Skip to content

Commit 1c39c78

Browse files
committed
Added NotFound Page; Added BaseController with basic navBack Routing;
1 parent 07454cc commit 1c39c78

8 files changed

+73
-9
lines changed

webapp/controller/App.controller.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
sap.ui.define([
2-
"sap/ui/core/mvc/Controller"
3-
], function(Controller) {
2+
"com/mrb/UI5-Navigation-and-Routing/controller/BaseController"
3+
], function(BaseController) {
44
"use strict";
55

6-
return Controller.extend("com.mrb.UI5-Navigation-and-Routing.controller.App", {});
6+
return BaseController.extend("com.mrb.UI5-Navigation-and-Routing.controller.App", {});
77
});

webapp/controller/BaseController.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
sap.ui.define([
2+
"sap/ui/core/mvc/Controller",
3+
"sap/ui/core/routing/History",
4+
"sap/ui/core/UIComponent"
5+
], function (Controller, History, UIComponent) {
6+
"use strict";
7+
8+
return Controller.extend("sap.ui.demo.nav.controller.BaseController", {
9+
10+
getRouter: function () {
11+
return UIComponent.getRouterFor(this);
12+
},
13+
14+
onNavBack: function () {
15+
var oHistory, sPreviousHash;
16+
17+
oHistory = History.getInstance();
18+
sPreviousHash = oHistory.getPreviousHash();
19+
20+
if (sPreviousHash !== undefined) {
21+
window.history.go(-1);
22+
} else {
23+
this.getRouter().navTo("appHome", {}, true /*no history*/);
24+
}
25+
}
26+
27+
});
28+
29+
});

webapp/controller/Home.controller.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
sap.ui.define([
2-
"sap/ui/core/mvc/Controller"
3-
], function(Controller) {
2+
"com/mrb/UI5-Navigation-and-Routing/controller/BaseController"
3+
], function(BaseController) {
44
"use strict";
55

6-
return Controller.extend("com.mrb.UI5-Navigation-and-Routing.controller.Home", {});
6+
return BaseController.extend("com.mrb.UI5-Navigation-and-Routing.controller.Home", {});
77
});
88

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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.NotFound", {
6+
onInit: function () {
7+
}
8+
});
9+
});

webapp/i18n/i18n.properties

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@ title=UI5-Navigation-and-Routing
22
appTitle=UI5-Navigation-and-Routing
33
appDescription=App Description
44
iWantToNavigate=I want to navigate
5-
homePageTitle=Home
5+
homePageTitle=Home
6+
NotFound=Not Found
7+
NotFound.text=Sorry, but the requested resource is not available.
8+
NotFound.description=Please check the URL and try again.

webapp/i18n/i18n_en.properties

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@ title=UI5-Navigation-and-Routing
22
appTitle=UI5-Navigation-and-Routing
33
appDescription=App Description
44
iWantToNavigate=I want to navigate
5-
homePageTitle=Home
5+
homePageTitle=Home
6+
NotFound=Not Found
7+
NotFound.text=Sorry, but the requested resource is not available.
8+
NotFound.description=Please check the URL and try again.

webapp/manifest.json

+10-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@
8080
"viewPath": "com.mrb.UI5-Navigation-and-Routing.view",
8181
"controlId": "app",
8282
"controlAggregation": "pages",
83-
"transition": "slide",
83+
"transition": "slide",
84+
"bypassed": {
85+
"target": "notFound"
86+
},
8487
"async": true
8588
},
8689
"routes": [{
@@ -94,6 +97,12 @@
9497
"viewId": "home",
9598
"viewLevel": 1,
9699
"viewName": "Home"
100+
},
101+
"notFound": {
102+
"viewType": "XML",
103+
"viewId": "notFound",
104+
"viewName": "NotFound",
105+
"transition": "show"
97106
}
98107
}
99108
}

webapp/view/NotFound.view.xml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<mvc:View
2+
controllerName="com.mrb.UI5-Navigation-and-Routing.controller.NotFound"
3+
xmlns="sap.m"
4+
xmlns:mvc="sap.ui.core.mvc">
5+
<MessagePage
6+
title="{i18n>NotFound}"
7+
text="{i18n>NotFound.text}"
8+
description="{i18n>NotFound.description}"
9+
showNavButton="true"
10+
navButtonPress="onNavBack"/>
11+
</mvc:View>

0 commit comments

Comments
 (0)