Skip to Content
0
Former Member
Aug 02, 2014 at 12:43 PM

Problem on navigation in SplitApp, onBeforeShow only ran in the first time

215 Views

Hi Experts,

I am new learner on SAPUI5, and I met a problem, I create a Page using SplitApp, the Default Master Page is a list, the Default Detail Page is a welcome page(Detail Page1), and when I click on the list on Master Page, the Detail Page will move to information page(Detail Page2).

The code in the index controller is:

onInit: function() { this.app = sap.ui.getCore().byId("CustomerApp"); var bus = sap.ui.getCore().getEventBus();

bus.subscribe("nav", "to", this.navToHandler, this);

bus.subscribe("nav", "back", this.navBackHandler, this);

},

navToHandler : function(channelId, eventId, data) {

if (data && data.id) {

... this.app.to(data.id, "slide", data.data) } }

The code in the information page(Detail Page2):

this.addEventDelegate({

// not added the controller as delegate to avoid controller functions with similar names as the events

onBeforeShow : function(evt) {

if (evt.data.context != null) {

//var secondViewModel = new sap.ui.model.json.JSONModel();

//secondViewModel.setData(evt.data);

this.setBindingContext(evt.data.context);

var DetailObjHeader = new sap.ui.getCore().byId("DetailObjHeader");

DetailObjHeader.setModel(evt.data.context.oModel);

DetailObjHeader.bindElement(evt.data.context.sPath);

}

}

}, this );

When I click the list on Master Page for the first time, the Detail page move to the information page(Detail Page2) with the correct data binding.

However when I click on it on the second time, the binding data on Detail Page2 was not refresh, I debugged on the code, found that:

in the first time: after this.app.to(data.id, "slide", data.data), the method onBeforeShow in Detail Page2 will be triggered, then the program worked fine.

in the second time: after this.app.to(data.id, "slide", data.data), the method onBeforeShow in Detail Page2 would be never triggered again, unless I move the Detail Page1 then move to Detail Page2, the method onBeforeShow will be called again.

Anyone know how to solve the problem?

Thanks and Best regards,

Dylan Ding