on 11-01-2017 2:49 PM
I have a UI5 app with three different pages.
The problem I have is that when trying to go back to a page for the second time, the onInit()
function doesn't get called. It seems like the browser caches the data on the screen and does not reset the values as I want it to. I have to refresh the browser in order for that to work.
Here is my routing configuration:
routing: {
config: {
routerClass: "sap.m.routing.Router",
viewPath: "BatchProcessing.view",
controlId: "rootControl",
controlAggregation: "pages",
viewType: "XML"
},
routes: [
{
name: "page1",
pattern: "",
target: "page1"
},
{
name: "page2",
pattern: "Page2",
target: "page2"
},
{
name: "page3",
pattern: "Page3",
target: "page3"
}
],
targets: {
page1: {
viewName: "InputsView",
viewLevel: 0
},
page2: {
viewName: "TableView",
viewLevel: 1
},
page3: {
viewName: "DetailsView",
viewLevel: 3
}
}
}
Here are the code snippets for the different controllers where I switch pages
controller 1
onToPage2 : function () {
this.getOwnerComponent().getRouter().navTo("page2");
},
controller 2
onToPage1 : function () {
// data = [];
this.getOwnerComponent().getRouter().navTo("page1");
},
controller 3
onToPage2 : function () {
this.getOwnerComponent().getRouter().navTo("page2");
},
Hi Peter,
In all 3 controllers in init() method you have to register handleroutematched() method. You can do it as below.
Init : function(){
this.getRouter().getRoute("model").attachPatternMatched(this._onObjectMatched, this);
}
// Define this method in same controller and check for the route
_onObjectMatched : function (oEvent) {
var oParameters = oEvent.getParameters();
if (oParameters.name == "model") {
// if route matched do your actions
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
oninit only get called once.
you can routematched event to do some additional work after each naviation
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.