Skip to content

Commit 08791dc

Browse files
committed
Added everything for Step 16: Handle Invalid Hashes by Listening to Bypassed Events
1 parent 304afbd commit 08791dc

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

webapp/controller/App.controller.js

+23-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
11
sap.ui.define([
2-
"com/mrb/UI5-Navigation-and-Routing/controller/BaseController"
3-
], function(BaseController) {
4-
"use strict";
2+
"com/mrb/UI5-Navigation-and-Routing/controller/BaseController",
3+
"sap/base/Log"
4+
], function (BaseController, Log) {
5+
"use strict";
56

6-
return BaseController.extend("com.mrb.UI5-Navigation-and-Routing.controller.App", {});
7+
return BaseController.extend("com.mrb.UI5-Navigation-and-Routing.controller.App", {
8+
onInit: function () {
9+
// This is ONLY for being used within the tutorial.
10+
// The default log level of the current running environment may be higher than INFO,
11+
// in order to see the debug info in the console, the log level needs to be explicitly
12+
// set to INFO here.
13+
// But for application development, the log level doesn't need to be set again in the code.
14+
Log.setLevel(Log.Level.INFO);
15+
16+
var oRouter = this.getRouter();
17+
18+
oRouter.attachBypassed(function (oEvent) {
19+
var sHash = oEvent.getParameter("hash");
20+
// do something here, i.e. send logging data to the backend for analysis
21+
// telling what resource the user tried to access...
22+
Log.info("Sorry, but the hash '" + sHash + "' is invalid.", "The resource was not found.");
23+
});
24+
}
25+
});
726
});

0 commit comments

Comments
 (0)