odatasapui5mockserver

How to get access of MockData from my Controller SapUI5


please i need your help. i try to get mockdata to fill my simpleform without success. I have followed the example of sap Hana to configure my mockserver.

the mockserver is working fine but i don't know how to get the mockdata on my view controller. Please can you help me. Her are my differents code

mockdata (Informations.js)

[{

        "Destination": "12D13E456S7",
        "Customer": "Uni Mannheim",
        "Position": "1237",
        "TaskNr": 87654321,
        "Adress": "COL 1234",
        "Remark": "Ordinateur non utilisable",
        "Order": "A4585Qwe84"   
    }]

manifest.json

{
  "_version": "1.32.0",
  "sap.app": {
    "id": "Informations",
    "type": "application",
    "i18n": "i18n/i18n.properties",
    "applicationVersion": {
      "version": "1.0.0"
    },
    "dataSources": {
      "InformationRemote":{
        "uri": "/",
        "type": "OData",
        "settings": {
          "odataVersion": "2.0",
          "localUri": "localService/metadata.xml"
        }
      }
    },
    "title": "{{appTitle}}",
    "description": "{{appDescription}}",
    "resources": "resources.json",
    "ach": "ach"
  },
  "sap.ui": {
    "technology": "UI5",
    "icons": {
      "icon": "sap-icon://task",
      "favIcon": "",
      "phone": "",
      "phone@2": "",
      "tablet": "",
      "tablet@2": ""
    },
    "deviceTypes": {
      "desktop": true,
      "tablet": true,
      "phone": true
    }
  },

  "sap.ui5": {
    "flexEnabled": false,
    "rootView": {
      "viewName": "Informations.view.Main",
      "type": "XML",
      "async": true,
      "id": "Main"
    },
    "dependencies": {
            "minUI5Version": "1.93.0",
      "libs": {
        "sap.ui.core": {},
        "sap.m": {},
        "sap.ui.layout": {}
      }
    },
    "contentDensities": {
      "compact": true,
      "cozy": true
    },
    "models": {
      "i18n": {
        "type": "sap.ui.model.resource.ResourceModel",
        "settings": {
          "bundleName": "Informations.i18n.i18n"
        }
      },
      "":{
        "dataSource": "InformationRemote",
        "preload": true
      }
    },
    "resources": {
      "css": [
        {
          "uri": "css/style.css"
        }
      ]
    },
    "routing": {
      "config": {
        "routerClass": "sap.m.routing.Router",
        "viewType": "XML",
        "async": true,
        "viewPath": "Informations.view",
        "controlAggregation": "pages",
        "controlId": "app",
        "clearControlAggregation": false
      },
      "routes": [
        {
          "name": "RoutevwInformation",
          "pattern": "RoutevwInformation",
          "target": ["TargetvwInformation"]
        }
      ],
      "targets": {
        "TargetvwInformation": {
          "viewType": "XML",
          "transition": "slide",
          "clearControlAggregation": false,
          "viewId": "Main",
          "viewName": "Main"
        }
      }
    }
  }
}

Please guy how can i do to get mockdata in view shall i implement something in the viewController? i really don't know how to do it.

Thanks in advance


Solution

  • I found out what to do I just have to do something like this.

    var oModel = new sap.ui.model.odata.v2.ODataModel("myUrl");
    sap.ui.getCore().setModel(oModel);