Reputation: 21
Is there any way by which we can reload the whole SAPUI5 application?
When a SAPUI5 app is called, onInit() function is called and we are initializing some settings for view here. Say if some change (like selection of a checkbox in master view) requires the whole application to be reset, can we reload the application and call onInit() function again to correct our initial settings? Is there any trigger mechanism by which we can call onInit() function explicitly?
Thank you in advance for your suggestions.
Regards, Raja
Upvotes: 2
Views: 10873
Reputation: 41
Sometimes you cannot directly use the window global variable in sapui5.
Refer to this page: https://help.sap.com/viewer/825270ffffe74d9f988a0f0066ad59f0/CF/en-US/7d0dba71a2cb45ebb1959daba904ca99.html?q=location%20reload
var myLocation = location;
myLocation.reload();
Upvotes: 1
Reputation: 467
I suggest you to use some kind of intercommunication (e.g.: EventBus) between your Controller instances, from the master view notify your Controllers to rerun initialization logic like follows:
onInit
onInit
subscribe to reinitialize eventController.js
:
function onInit() {
this._initialize();
EventBus.subscribe('reinitialize', this._initialize);
}
funcion _initialize() {
// init logic
}
MasterController.js
:
function onSelectionChange() {
EventBus.publish('reinitialize');
}
Upvotes: 1
Reputation: 4920
If you have the need to reload or reset your application, then I would think your app suffers from a major design flaw... This is definitely something I would look into first if I were you!
However, to answer your question, why not move the initialization code into its own function, and call that function from the onInit()
event handler and whenever you need to reset your app?
Upvotes: 3