Quantcast
Channel: SCN : Discussion List - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 6412

SAPUI5 Navigation between sap.m.App and sap.m.splitApp

$
0
0

Hi guys,

 

I'm new in SAPUI5 development and I'd like to know how can I navigate through different apps definitions.

 

In my case, I'm developing a mobile app that uses the sap.m.App and in some views I'd like to use sap.m.splitApp.

 

First, I have a login page and a tile container with some options. Depending on the user's choice, I'm showing an splitApp with master and detail page.

 

Main App Controller: With this method I can navigate to my splitApp view

 

toApp: function (pageId, context) {

 

  var app = this.getView().app;

 

  // load page on demand

  var master = ("Login" === pageId);

  if (app.getPage(pageId, master) === null) {

  var page = sap.ui.view({

  id : pageId,

  viewName : "view." + pageId,

  type : "JS",

  viewData : { component : this }

  });

  page.getController().nav = this;

  app.addPage(page, true);

  console.log("app controller > loaded page: " + pageId);

  }

 

  // show the page

  app.to(pageId);

 

  // set data context on the page

  if (context) {

  var page = app.getPage(pageId);

  page.setBindingContext(context);

  }

},

 

 

Ticket.view.js: Here I add my master and detail pages to my App

 

createContent : function(oController) {

  // to avoid scroll bars on desktop the root view must be set to block display

  this.setDisplayBlock(true);

 

  // create app

  this.app = new sap.m.SplitApp();

 

 

  // load the master page

  var master = sap.ui.xmlview("MyTicketsList", "view.MyTicketsList");

  master.getController().nav = this.getController();

  this.app.addPage(master, true);

 

  // load the empty page

  var empty = sap.ui.xmlview("Empty", "view.Empty");

  this.app.addPage(empty, false);

 

  returnthis.app;

}

 

And it's working fine. I can navigate to my splitApp. The problem is that I have to go back to my Main page (with the tile container) in case the user choice other option. I hope to do that using the following method in my Ticket.controller.js

 

back : function (pageId) {

  this.getView().app.backToPage(pageId);

}

 

And, on the MyTicketsList controller, I did the handleNavButtonPress using:

 

this.nav.back("MainPage");


But this, doesn't work!


How can I navigate through apps? Or, perhaps, How is the better way to create my splitter pages view, with Master and Detail pages?


Thanks in advance!


Viewing all articles
Browse latest Browse all 6412

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>