Skip to Content
avatar image
Former Member

Passing Parameters one view to another view in xml

Hi Professionals,

I'm working on the "Passing Parameters one view to another view in xml view". I have done all but in the last error is appearing in "setModel(oModel)". Here is my code

onInit : function() { var oModel = new sap.ui.model.json.JSONModel("z/product.json"); this.getView().setModel(oModel);


onTablePress : function(oEvent){ var that = this; var oModel = new sap.ui.model.json.JSONModel(); sap.ui.getCore().setModel(oModel, "Name"); var x = []; for (var i = 0; i<oEvent.oSource.mAggregations.cells.length; i++) { x [i] = oEvent.oSource.mAggregations.cells[i].mProperties.text; } var oRouter = sap.ui.core.UIComponent.getRouterFor(that); oRouter.navTo("navtable"); oModel.setData(x); var oMax = this.getView("zdemo_table.zdemo_table.navtable").byId("idObjectHeader").setModel(oModl);


Please any one help me out from this problem.

thank you in advance.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Apr 18, 2017 at 07:36 AM

    remove last line in onTablePress function, and get the model in onInit function of second view (navigated view) controller as,

    var oModel = sap.ui.getCore().getModel("Name");

    //now set oModel to your view/control here

    Add comment
    10|10000 characters needed characters exceeded

    • you are doing wrong! this is not the right way to do this, but in your case flow would be as below:

      get/prepare data in first view -> set data to a model in first view-> set model to core in first view-> get and set model in second view -> binded data will be shown in second view

      As you have already set a named model "sap.ui.getCore().setModel(oModel, "Name");" in first view.


      in second view onInit function write below code only

      var oModel = sap.ui.getCore().getModel("Name");

      // in debug mode you can verify whether you are getting model and respective data or not


  • Apr 19, 2017 at 10:01 AM


    Instead of accessing the model you can even pass the data in navigation .

    Just check out the navigation example :



    Add comment
    10|10000 characters needed characters exceeded