How to do navigation between two views using JS view in openui5 for desktop application?

2.5k Views Asked by At

As I am a newbie to openui5, I can't navigate from one view to another view using a button click.

How do I do that? I searched a lot and I got frustrated. While searching mostly I got the data related to sap.m(mobile) but I need code sample for sap.ui.commons(desktop) or any other link would be helpful.

Can anyone share some sample code for sap.ui.commons (Routing or tab navigation) not for sap.m?

2

There are 2 best solutions below

0
On

There are different options for this:

1.Option:

is to use the sap.ui.ux3.Shell see here

2.Option:

using a Router

3.Option:

or by hiding a view and showing it like this:

sap.ui.getCore().byId('View1').setVisible(false);
sap.ui.getCore().byId('View2').setVisible(true);
0
On

Use Router of the SAPUI5 Application:

Sample code snippet :

var oRouter = sap.ui.core.routing.Router.getRouter("appRouter");
//can also use directly this.oRouter.navTo if you're extending scaffloding OR base controllers of SAP UI5.
oRouter.navTo("samplePattern",oContext,false);