We are in the process of building a web application that allows users to "plugin" their own views (pages). When they create there own views there are a number of activities that are common across all pages that occur in the onInit() and onExit() methods, additionally, we may provide additional utility functions that should be available to the controller.
Currently when creating a controller the standard is to use sap.ui.controller("some.name", { controller specific functionality } ); I would like to create a sap.ui.MyController("some.name", { controller specific functionality }); that contains the utility functions and extra functionality in the LifeCycle methods so that these are automatically available to anyone defining this type of controller.
I believe the documentation I need to reference is boilerplate code for typed Controller however I am unsure on how this can be used
I assume that I define the controller abc/xyz/MYController.js
jQuery.sap.declare({modName:"abc.xyz.MYController", type:"controller"}); // declaring a special type of module
abc.xyz.MYController = function () { // the constructor
sap.ui.core.mvc.Controller.apply(this, arguments);
};
jQuery.sap.require("sap.ui.core.mvc.Controller"); // this is currently required, as the Controller is not loaded by default
abc.xyz.MYController.prototype = jQuery.sap.newObject(sap.ui.core.mvc.Controller.prototype); // chain the prototypes
/* end of boilerplate code for typed Controller */
abc.xyz.MYController.prototype.onInit = function() {
// modify control tree - this is the regular lifecycle hook
console.log("Inside my new controller.");
};
Then use it in app/pageController.controller.js ...
jQuery.sap.require("abc.xyz.MYController");
abc.xyz.MYController("app.pageController", { ..... });
When I try this I get the Error
Any help with this would be appreciated.
Regards,
Trevor