Skip to Content

Component.JS dependency and paramater JSONModel undefined

Gents,

I can't understand why the JSONModel dependency within Component.JS returns undefined within my own application.

For example:

https://sapui5.hana.ondemand.com/test-resources/sap/m/demokit/cart/index.html

Breakpoint inside Component.JS before and after (within init function), we check parameter JSONModel.

When i do the same within my own application, inside the init function, JSONModel returns undefined :/

Can someone help me please!?

Its simular to this question but can't find the proper solution to fix it...

https://archive.sap.com/discussions/thread/3815876

Kind Regards,

Martin Gerritsen

good.png (210.8 kB)
bad.png (170.6 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Jun 28, 2017 at 07:56 AM

    Problem solved but the question WHY is still open... maybe someone can explain it...

    If none of the defined dependencies is called inside the function e.g. init(..), the declared parameters e.g. JSONModel is still undefined (see picture left side).

    If JSONModel is called inside e.g. init(..), the framework is smart enough to make sure JSONModel is available (see picture right side, yellow).

    If your testing without new JSONModel(..) inside init(..) and you aware of the undefined, why should you even try to implement the code as shown on the right side of the picture?

    I think the framewok is aware of the defined dependencies and from a performance perspective compiles the functions inside e.g. extended component, checks the dependencies and make sure only those who needed (e.g. JSONModel) are available. Other parameters are still undefined unless the implementation of e.g. init(..) refers to it.

    Add comment
    10|10000 characters needed characters exceeded

  • Jun 27, 2017 at 06:36 PM

    what's your html code?

    Add comment
    10|10000 characters needed characters exceeded

    • manifest.json of the SAP application

      {
        "_version": "1.1.0",
        "sap.app": {
      	"_version": "1.1.0",
      	"id": "sap.ui.demo.wt",
      	"type": "application",
      	"i18n": "i18n/i18n.properties",
      	"title": "{{appTitle}}",
      	"description": "{{appDescription}}",
      	"applicationVersion": {
      	  "version": "1.0.0"
      	},
      	"dataSources": {
      	  "invoiceRemote": {
      		"uri": "/destinations/northwind/V2/Northwind/Northwind.svc/",
      		"type": "OData",
      		"settings": {
      		  "odataVersion": "2.0"
      		}
      	  }
      	}
        },
        "sap.ui": {
      	"_version": "1.1.0",
      	"technology": "UI5",
      	"deviceTypes": {
      	  "desktop": true,
      	  "tablet": true,
      	  "phone": true
      	},
      	"supportedThemes": [
      		"sap_hcb",
      		"sap_belize"
      	]
        },
        "sap.ui5": {
      	"_version": "1.1.0",
      	"rootView": "sap.ui.demo.wt.view.App",
      	"dependencies": {
      	  "minUI5Version": "1.30",
      	  "libs": {
      		"sap.m": {}
      	  }
      	},
      	"models": {
      	  "i18n": {
      		"type": "sap.ui.model.resource.ResourceModel",
      		"settings": {
      		  "bundleName": "sap.ui.demo.wt.i18n.i18n"
      		}
      	  },
      	  "invoice": {
      		"dataSource": "invoiceRemote"
      	  }
      	},
      	"resources": {
      	  "css": [
      		{
      		  "uri": "css/style.css"
      		}
      	  ]
      	},
      	"routing": {
      	  "config": {
      		"routerClass": "sap.m.routing.Router",
      		"viewType": "XML",
      		"viewPath": "sap.ui.demo.wt.view",
      		"controlId": "app",
      		"controlAggregation": "pages"
      	  },
      	  "routes": [
      		{
      		  "pattern": "",
      		  "name": "overview",
      		  "target": "overview"
      		},
      		{
      		  "pattern": "detail/{invoicePath}",
      		  "name": "detail",
      		  "target": "detail"
      		}
      	  ],
      	  "targets": {
      		"overview": {
      		  "viewName": "Overview"
      		},
      		"detail": {
      		  "viewName": "Detail"
      		}
      	  }
      	}
        }
      }

      manifest.json of my own application

      {
        "_version": "1.1.0",
        "sap.app": {
      	"_version": "1.1.0",
      	"id": "ui5bp",
      	"type": "application",
      	"i18n": "i18n/i18n.properties",
      	"title": "{{appTitle}}",
      	"description": "{{appDescription}}",
      	"applicationVersion": {
      	  "version": "1.0.0"
      	},
        },
        "sap.ui": {
      	"_version": "1.1.0",
      	"technology": "UI5",
      	"deviceTypes": {
      	  "desktop": true,
      	  "tablet": true,
      	  "phone": true
      	},
      	"supportedThemes": [
      		"sap_belize"
      	]
        },
        "sap.ui5": {
      	"_version": "1.1.0",
      	"rootView": {
      	  "viewName": "ui5bp.view.App",
      	  "type": "XML",
      	  "id": "app"
      	},
      	"dependencies": {
      	  "minUI5Version": "1.30",
      	  "libs": {
      		"sap.m": {}
      	  }
      	},
      	"models": {
      	  "i18n": {
      		"type": "sap.ui.model.resource.ResourceModel",
      		"settings": {
      		  "bundleName": "ui5bp.i18n.i18n"
      		}
      	  }
      	}
        }
      }