Skip to Content

sap.ui.define: JSONModel is not defined(…)

Hi,

whats wrong with my path?

UIComponent and Device are fine, but JSONModel  is not defined.

Get the error: Uncaught ReferenceError: JSONModel is not defined(…)

Could somebody help me?

Thanks

JSONModel.PNG (26.3 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Oct 21, 2015 at 04:40 PM

    Can you post the code where you're trying to use the JSONModel ?

    Add comment
    10|10000 characters needed characters exceeded

    • <!DOCTYPE html>

      <html>

      <head>

          <meta http-equiv="X-UA-Compatible" content="IE=edge" />

          <meta charset="UTF-8">

          <title>UI5 Boilerplate Fiori</title>

          <!-- UI5 Bootstrap with OpenUI5 -->

          <script

        id="sap-ui-bootstrap"

        src="https://openui5.hana.ondemand.com/resources/sap-ui-core.js"

        data-sap-ui-theme="sap_bluecrystal"

        data-sap-ui-libs="sap.m,sap.ui.commons,sap.ui.table,sap.ui.ux3"

        data-sap-ui-bindingSyntax="complex"

        data-sap-ui-compatVersion="edge"

        data-sap-ui-preload="async"

        data-sap-ui-resourceroots='{

        "ui5bp": "./"

        }'>

        </script>

        <script>

        sap.ui.getCore().attachInit(function () {

        new sap.m.Shell({

        app: new sap.ui.core.ComponentContainer({

        name: "ui5bp",

        height: "100%"

        })

        }).placeAt("content");

        });

        </script>

      </head>

      <body class="sapUiBody" id="content">

      </body>

      </html>

  • Oct 21, 2015 at 05:28 PM

    if you remove it from line 5 and line 3 and use full path like

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

    does it work?

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 21, 2015 at 08:43 PM

    Could it have something to do with the manifest.json file?

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 22, 2015 at 08:02 AM

    Thank you all for great help!

    After I initialized JSONModel with this coding, it was defined.

                var rootPath = jQuery.sap.getModulePath("ui5bp");

                var oModel = new JSONModel(jQuery.sap.getModulePath("ui5bp", "/model/menu.json"));

                this.getView().setModel(oModel);

    I thought the JSONModel is automatically initialized with the entries inside of the manifest(ab Version 1.30) and I don't need the whole syntax.

    Unfortunately I didn't find a sample for the new syntax (inside of manifest), if I want to load a local json file.

    Add comment
    10|10000 characters needed characters exceeded