Skip to content

Commit

Permalink
Added NotFound Page; Added BaseController with basic navBack Routing;
Browse files Browse the repository at this point in the history
  • Loading branch information
wridgeu committed Mar 8, 2020
1 parent 07454cc commit 1c39c78
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 9 deletions.
6 changes: 3 additions & 3 deletions webapp/controller/App.controller.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sap.ui.define([
"sap/ui/core/mvc/Controller"
], function(Controller) {
"com/mrb/UI5-Navigation-and-Routing/controller/BaseController"
], function(BaseController) {
"use strict";

return Controller.extend("com.mrb.UI5-Navigation-and-Routing.controller.App", {});
return BaseController.extend("com.mrb.UI5-Navigation-and-Routing.controller.App", {});
});
29 changes: 29 additions & 0 deletions webapp/controller/BaseController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
sap.ui.define([
"sap/ui/core/mvc/Controller",
"sap/ui/core/routing/History",
"sap/ui/core/UIComponent"
], function (Controller, History, UIComponent) {
"use strict";

return Controller.extend("sap.ui.demo.nav.controller.BaseController", {

getRouter: function () {
return UIComponent.getRouterFor(this);
},

onNavBack: function () {
var oHistory, sPreviousHash;

oHistory = History.getInstance();
sPreviousHash = oHistory.getPreviousHash();

if (sPreviousHash !== undefined) {
window.history.go(-1);
} else {
this.getRouter().navTo("appHome", {}, true /*no history*/);
}
}

});

});
6 changes: 3 additions & 3 deletions webapp/controller/Home.controller.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
sap.ui.define([
"sap/ui/core/mvc/Controller"
], function(Controller) {
"com/mrb/UI5-Navigation-and-Routing/controller/BaseController"
], function(BaseController) {
"use strict";

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

9 changes: 9 additions & 0 deletions webapp/controller/NotFound.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
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.NotFound", {
onInit: function () {
}
});
});
5 changes: 4 additions & 1 deletion webapp/i18n/i18n.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ title=UI5-Navigation-and-Routing
appTitle=UI5-Navigation-and-Routing
appDescription=App Description
iWantToNavigate=I want to navigate
homePageTitle=Home
homePageTitle=Home
NotFound=Not Found
NotFound.text=Sorry, but the requested resource is not available.
NotFound.description=Please check the URL and try again.
5 changes: 4 additions & 1 deletion webapp/i18n/i18n_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ title=UI5-Navigation-and-Routing
appTitle=UI5-Navigation-and-Routing
appDescription=App Description
iWantToNavigate=I want to navigate
homePageTitle=Home
homePageTitle=Home
NotFound=Not Found
NotFound.text=Sorry, but the requested resource is not available.
NotFound.description=Please check the URL and try again.
11 changes: 10 additions & 1 deletion webapp/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@
"viewPath": "com.mrb.UI5-Navigation-and-Routing.view",
"controlId": "app",
"controlAggregation": "pages",
"transition": "slide",
"transition": "slide",
"bypassed": {
"target": "notFound"
},
"async": true
},
"routes": [{
Expand All @@ -94,6 +97,12 @@
"viewId": "home",
"viewLevel": 1,
"viewName": "Home"
},
"notFound": {
"viewType": "XML",
"viewId": "notFound",
"viewName": "NotFound",
"transition": "show"
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions webapp/view/NotFound.view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<mvc:View
controllerName="com.mrb.UI5-Navigation-and-Routing.controller.NotFound"
xmlns="sap.m"
xmlns:mvc="sap.ui.core.mvc">
<MessagePage
title="{i18n>NotFound}"
text="{i18n>NotFound.text}"
description="{i18n>NotFound.description}"
showNavButton="true"
navButtonPress="onNavBack"/>
</mvc:View>

0 comments on commit 1c39c78

Please sign in to comment.