SAP / openui5

OpenUI5 lets you build enterprise-ready web applications, responsive to all devices, running on almost any browser of your choice.
http://openui5.org
Apache License 2.0
2.95k stars 1.23k forks source link

Preloaded JSON ignored while instantiating JSON Model #2623

Closed gelzi closed 5 years ago

gelzi commented 5 years ago

OpenUI5 version: 1.68.1

Browser/version (+device/version): Chrome 76.0.3809.87

Any other tested browsers/devices(OK/FAIL): -

Steps to reproduce the problem:

  1. Create a JSON Model in manifest.json as follows:
    {
    "_version": "1.8.0",
    "sap.app": {
        "id": "myAppID",
    },
    "dataSources": {
        "application_datasource": {
                "uri": "/model/application.json",
                "type": "JSON"
            }
        }
    },
    "sap.ui5": {
        "models": {
            "application": {
                    "type": "sap.ui.model.json.JSONModel",
                    "dataSource": "application_datasource"
                }
            }
        }
    }
  2. create a component-preload.js via ui5-tooling
  3. load the page.

What is the expected result? As the application.json is part of the component-preload.js, it will not be fetched from the webserver.

What happens instead? The entry in component-preload.js is being ignored and the file is fetched from the webserver.

hristop commented 5 years ago

Hi @gelzi,

The manifest is the thing that is loaded first and is the place where the needed resources for the application are described. In this line of thought it will send the requests for each resource, including the Components-preload file, described in it. So by the time that your Components-preload is loaded, the request for the model is already made.

If you want to cache it like this, you need to create the model after that (in the init method of the application for example).

Best Regards, Hristo