cancel
Showing results for 
Search instead for 
Did you mean: 

Routing and navigating to specific page

SergioG_TX
Active Contributor
0 Kudos

I have a question about Routing. I have an example where I am using eventbus which yes I takes me to my next view depending if I am navigation to or back, etc.

is there a way for me to use event bus and also be able to go directly to a page in my app, such as using:  urlToApp/#viewName  or something similar? any help would be appreciated?    

I believe the alternative would be something using routing, but I haven't found a good example for it.

thank you in advance,

Sergio

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Sergio,

              Based on my understanding i am giving this solution.

You can navigate to specific page using event bus by  using the following code

var bus = sap.ui.getCore().getEventBus();

bus.publish("nav", "to", {

id :"pageId",

data : { context :context1}

}

pageId---->viewId

Thanks & Regards,

Bindu


former_member206705
Participant
0 Kudos

Hi Sergio,

Yes, routing is the way out. Refer this documentation for help.

Thanks and best regards,

Shilpa

0 Kudos

The refer tutorial does not work.

Do u have other resources regarding Routing .

Please post.

SergioG_TX
Active Contributor
0 Kudos

First of all you have to load your views:

sap.ui.localResources('folderWithViews');

then follow this example:

JsDoc Report - SAP UI development Toolkit for HTML5 - API Reference - sap.ui.core.routing.Router

your code will end up with something like this:

//Somewhere at the start of your application

var aRoutes = [ { pattern : "product/{id}", // will be the url and from has to be provided in the data name : "specificProduct" // name used for listening or navigating to this route } ];

var oRouter = new sap.ui.core.routing.Router(aRoutes); //this is used to retrieve the instance again

oRouter.register("appRouter"); //starts reacting on the hashchange + parses the current hash and notifies callbacks

oRouter.initialize();

 

also, look at section 8.10 in the SAPUI5 Developer Guide for SAP HANA Document Version 1.0  2014-05-28