cancel
Showing results for 
Search instead for 
Did you mean: 

SAP UI5-Component.js-Routing

0 Kudos

Hello Experts,

I had a query regarding components.js file. I have two pages page1 and page2. In page1 there are different button which we click and there is routing to the information of these button but the page remains the same, the URL gets appended with #action. However, I also need to do the routing to another page(page2) by clicking on another button(x1) with # in URL ..../#xx. This is my components.js file. Could you suggest me something?


component.js
jQuery.sap.declare("app.Component");
jQuery.sap.require("sap.ui.core.routing.Router");
sap.ui.core.UIComponent.extend("app.Component", {
metadata : {
routing: {
config: {
routerClass: "sap.ui.core.routing.Router",
viewType: "JS",
viewPath: "",
controlId: "container",
controlAggregation: "items",
transition: "slide",
async: true,
clearControlAggregation: true
},
routes: [{
pattern: ["", "button1action1"],
name: "action1",
target: "action1",
"controlAggregation": "content"
}, {
pattern: "button2action2",

name: "action2",
target: "action2",
controlAggregation: "content"

}],
targets: {
"action1": {
"viewName": "modules.action1.action1TestsView"
},
"action2": {
"viewName": "modules.action2.action2TestsView"
}

}
}
}, init : function() {
sap.ui.core.UIComponent.prototype.init.apply(this, arguments);
this.getRouter().initialize();
}, destroy : function() {
sap.ui.core.UIComponent.prototype.destroy.apply(this, arguments);
}, createContent : function() {
var oView = new sap.ui.jsview("xyz", "app.XYZView");
oView.setDisplayBlock(true);
return oView;
}
});

Accepted Solutions (0)

Answers (1)

Answers (1)

brian_keenan
Contributor
0 Kudos

you can navigate by using the NavTo function of the Router

sap.ui.core.UIComponent.getRouterFor(this).navTo("action2", {... whatever arguments you want to pass... });

0 Kudos

Thank you Brian. I will try this method.

Sincere regards,
Meghna Anand