cancel
Showing results for 
Search instead for 
Did you mean: 

Passing a Value Between two SAPUI5 Mobile App Pages

Former Member
0 Kudos

Hi Guys,

I want to pass a Value from Page1 of my SAPUI5 Mobile App to Page2. But I don't know how can I pass it and then use this value on Page2 (in MVC Architecture). Please guide me in this regard.

Thanks and best regards.

Fahad.

Accepted Solutions (1)

Accepted Solutions (1)

AndreasKunz
Advisor
Advisor
0 Kudos

Hi Fahad,

please check the respective documentation at

https://sapui5.netweaver.ondemand.com/sdk/#docs/guide/MVC.1.html

and my answer in the other thread:

http://scn.sap.com/message/13854804#13854804

Regards

Andreas

Answers (1)

Answers (1)

former_member182048
Active Contributor
0 Kudos

Hi Fahad

Take a look at the following example

sapui5-static/test-resources/sap/m/internal/demo/DemoAppToDoList.html

Its a mobile application using MVC. It has 2 pages notes and details.

from notes.controller.js


showDetails : function(record) {

          if (!this._detailsView) {

                    this._detailsView = sap.ui.jsview("todolist.details");

          }

          this._detailsView.getController().show(record);

When the user drills into a line of noteList the function showDetails in the notes.controller is called.

This then calls the details.controller via the details.view and passes the current record.

A nicer solution is the one Andreas suggested to you earlier in another post, use the EventBus. It is available in the latest version, very easy to use, below is a simple example of using events to pass data. When navigating between pages you can use events, subscribe on one publish on another.

$.sap.require("sap.ui.core.EventBus");

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

var params = {param1: "helloWorld"};

show = function(sChannelId, sEventId, oData){

  alert(oData.param1);

};

//to subscribe

oBus.subscribe("myChannel","goToDetailsPage", show);

//to publish data between pages

oBus.publish("myChannel","goToDetailsPage",params);

Cheers

John P

Sorry Andreas, when i started my response there were no replies.

For those wanting to see a sap.ui.core.EventBus example http://jsbin.com/ojobiy/2/edit

Message was edited by: John Patterson