Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

getting error as app.addPage while creating fiori like apps

Hi,

While creating fiori like apps .I am getting following error at this.app.addPage(master, true);   as

Error Msg: Uncaught TypeError: Cannot read property 'addPage' of undefined

UI5.view.js

---------------------------------

sap.ui.jsview("sap.ui.demo.myFiori.ui5component.UI5", {

  getControllerName : function() {

  return "sap.ui.demo.myFiori.ui5component.UI5";

  },

createContent : function(oController) {

  var app = new sap.m.App();

  this.setDisplayBlock(true);

  var master = sap.ui.view({id:"Master",

  viewName:"sap.ui.demo.myFiori.ui5component.master", type:sap.ui.core.mvc.ViewType.JS});

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

  this.app.addPage(master, true);

  var detail = sap.ui.view({id:"Detail",

  viewName:"sap.ui.demo.myFiori.ui5component.detail", type:sap.ui.core.mvc.ViewType.JS});

  //app.addMasterPage(master).addDetailPage(detail);

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

  this.app.addPage(detail);

  //this.app.addPage(master);

  return app;

  }

});

master.view.js

--------------------------

sap.ui.jsview("sap.ui.demo.myFiori.ui5component.master", {

  getControllerName : function() {

  return "sap.ui.demo.myFiori.ui5component.master";

  },

  createContent : function(oController) {

  var list1 = new sap.m.List({

  id : "master", inset: false,

  press : function(oevent)

  {oController. handleListItemPress();}

  });

  var template = new sap.m.StandardListItem({

  title : "{SoId}"

  });

  list1.bindItems({path : "/SalesOrderCollection",template :template} );

  return list1;

master.controller.js

------------------------

sap.ui.controller("sap.ui.demo.myFiori.ui5component.master", {

  handleListItemPress : function (evt) {

  var context = evt.getSource().getBindingContext();

  this.nav.to("Detail1", context);

  }

});

  }

});

Tags:
Former Member
Former Member replied

As explained by Dennis, it's really two different things.

this.app assigns a member variable/ property to the object (in your case, the UI5 view object). In other programming languages like Java, it would be the same (this.app), on ABAP, it would be me->app.

var app instead creates a local variable (within the scope of the function). In Java, this would again be something like Object app = ... and in ABAP, it would be something like DATA lv_app TYPE ...

Let me stress again that this.app and app are really two different things. To make your code work, it's important to use either one consistently through the createContent function.

- Max

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question