SapUI5表 - 404未找到错误

时间:2015-04-09 11:41:46

标签: javascript html5 sapui5

我已经开始学习sap ui5了。我按照教程在这里创建了一张桌子,这就是我所拥有的。

的index.html:

<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>

        <script src="resources/sap-ui-core.js"
                id="sap-ui-bootstrap"
                data-sap-ui-libs="sap.ui.commons, sap.m, sap.ui.table, sap.ui.model, sap.ui.model.json"
                data-sap-ui-theme="sap_bluecrystal">
        </script>
        <!-- add sap.ui.table,sap.ui.ux3 and/or other libraries to 'data-sap-ui-libs' if required -->

        <script src="app/data.js"></script>
        <script src="app/app.js"></script>

    </head>
    <body class="sapUiBody" role="application">
        <div id="content"></div>
    </body>
</html>

app.js

var oTable = new sap.ui.table.Table({
    title: "My first table",
    visibleRowCount: 5,
    firstVisibleRow: 2,
    selectionMode: sap.ui.table.SelectionMode.Single,
    toolbar: new sap.ui.commons.Toolbar({
        items: [
            new sap.ui.commons.Button({
                text: "Toolbar button",
                press: function() {
                    alert("Toolbar button pressed");
                }
            })
        ]
    }),
    extenstion: [
        new sap.ui.commons.Button( {
            text: "Extenstion button",
            press: function() {
                alert("Extenstion button pressed");
            }
        })
    ]
});

oColumn = new sap.ui.table.Column({
    label: new sap.ui.commons.Label({
        text: "Last name"
    }),
    template: new sap.ui.commons.TextView().bindProperty("text", "lastName"),
    sortProperty: "lastName",
    filterProperty: "lastName",
    width: "200px"
});

var oCustomMenu = new sap.ui.commons.Menu();
oCustomMenu.addItem(new sap.ui.commons.MenuItem({
    text: "Custom Menu",
    select: function() {
        alert("Custom menu");
    }
}));

oColumn.setMenu(oCustomMenu);
oTable.addColumn(oColumn);

oTable.addColumn(new sap.ui.table.Column({
    label: new sap.ui.commons.Label({
        text: "ID"
    }),
    template: new sap.ui.commons.TextField().bindProperty("value", "firstName"),
    sortProperty: "name",
    filterProperty: "name",
    width: "100px"
}));

oTable.addColumn(new sap.ui.table.Column({
    label: new sap.ui.commons.Label({
        text: "First name"
    }),
    template: new sap.ui.commons.TextField().bindProperty("value", "firstName"),
    sortProperty: "name",
    filterProperty: "name",
    width: "100px"
}));

oTable.addColumn(new sap.ui.table.Column({
    label: new sap.ui.commons.Label({
        text: "First name"
    }),
    template: new sap.ui.commons.TextField().bindProperty("value", "firstName"),
    sortProperty: "name",
    filterProperty: "name",
    width: "100px"
}));

var oModel = new sap.ui.model.json.JSONModel();
oModel.setData({
    modelData: data
});

oTable.sort(oTable.getColumns()[0]);
oTable.placeAt("content");

data.js:

var data = [
    {firstName: "Michal", lastName: "Kohut", id: 358, phone: 4584250, rating: 5},
    {firstName: "Jan", lastName: "Pribrzdený", id: 157, phone: 1325124, rating: 1},
    {firstName: "Milena", lastName: "Dnesmameninova", id: 874, phone: 3698548, rating: 4}
]

我在eclipse中使用sapui5插件执行此操作。当我跑的时候我得到了这个错误:

Error messages

我对javascript和sapui5真的很陌生。你能帮我解决一下吗?

1 个答案:

答案 0 :(得分:0)

index.html中的sap.ui.model声明中不需要

sap.ui.model.jsondata-sap-ui-libs。删除语句中的两个库。

尝试使用:

<script src="resources/sap-ui-core.js" 
id="sap-ui-bootstrap"
data-sap-ui-libs="sap.ui.commons, sap.m, sap.ui.table"
data-sap-ui-theme="sap_bluecrystal">
</script>