mardi 24 octobre 2017

OpenUI5: can't instanate a model

As it is said in the 20 lesson of the walkthroug, i'm trying to instanate a model with Invoices.json. But as a result i receive "No data" in a List. I've compared all my sources with the onces they have in a tutorial, and they are the same (excluding urls in the index.html)

As far as I understand, the version of the SDK I use is "1.48.10" (i check it in a sap-ui-version.json), so the instanation should work.

Here is my index.html:

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <title>Walkthrough</title>
    <script src="http://localhost:63342/TestOprnUI5/resources/sap-ui-core.js"
            id="sap-ui-bootstrap"
            data-sap-ui-theme="sap_bluecrystal"
            data-sap-ui-libs="sap.m"
            data-sap-ui-compatVersion="edge"
            data-sap-ui-preload="async"
            data-sap-ui-resourceroots='{
        "sap.ui.demo.wt": "./testoprnui5/"
        }'>
    </script>
    <script>
        sap.ui.getCore().attachInit(function () {
            new sap.m.Shell({
                app: new sap.ui.core.ComponentContainer({
                    name: "sap.ui.demo.wt"
                })
            }).placeAt("content");
        });
    </script>
</head>
<body class="sapUiBody" id="content">
</body>
</html>

Here is InvoiceList.view,xml:

<mvc:View
        xmlns="sap.m"
        xmlns:mvc="sap.ui.core.mvc">
    <List
            headerText="{i18n>invoiceListTitle}"
            class="sapUiResponsiveMargin"
            width="auto"
            items="{invoice>/Invoices}" >
        <items>
            <ObjectListItem
                    title="{invoice>Quantity} x {invoice>ProductName}"/>
        </items>
    </List>
</mvc:View>

Here is App.view.xml:

<mvc:View
        controllerName="sap.ui.demo.wt.controller.App"
        xmlns="sap.m"
        xmlns:mvc="sap.ui.core.mvc"
        displayBlock="true">
    <App class="myAppDemoWT">
        <pages>
            <Page title="{i18n>homePageTitle}">
                <headerContent>
                    <Button
                            icon="sap-icon://hello-world"
                            press="onOpenDialog"/>
                </headerContent>
                <content>
                    <mvc:XMLView viewName="sap.ui.demo.wt.view.HelloPanel"/>
                    <mvc:XMLView viewName="sap.ui.demo.wt.view.InvoiceList"/>
                </content>
            </Page>
        </pages>
    </App>
</mvc:View>

Here is component.js:

sap.ui.define([
    "sap/ui/core/UIComponent",
    "sap/ui/model/json/JSONModel",
    "sap/ui/demo/wt/controller/HelloDialog"
], function (UIComponent, JSONModel, HelloDialog) {
    "use strict";
    return UIComponent.extend("sap.ui.demo.wt.Component", {
        metadata: {
            manifest: "json"
        },
        init: function () {
            // call the init function of the parent
            UIComponent.prototype.init.apply(this, arguments);
            // set data model
            var oData = {
                recipient: {
                    name: "World"
                }
            };
            var oModel = new JSONModel(oData);
            this.setModel(oModel);
            // set dialog
            this._helloDialog = new HelloDialog(this.getRootControl());
        },
        openHelloDialog: function () {
            this._helloDialog.open();
        }
    });
});

Here is the project structure:

TestOpenUI5
- resources
- testopenui5
-- controller
--- App.controller.js
--- HelloDialog.js
--- HelloPanel.controller.js
-- css
--- styles.css
-- i18n
--- i18n.properties
-- view
---  App.view.xml
---  HelloDialog.fragment.xml
---  HelloPanel.view.xml
---  InvoiceList.view.xml
-- Component.js
-- Invoices.json
-- manifest.json
- index.html
- Invoices.json

PS: i've tried to put Invoices.json to the different folders, to the root and to the /testopenui5 folder with the same result. PPS: it looks like Invoices are not included to the model, but how can i check it to be sure? And where can i find some logs?




Aucun commentaire:

Enregistrer un commentaire