UI5 - 找不到资源

时间:2015-03-18 14:54:54

标签: javascript sapui5

我正在使用https://openui5.hana.ondemand.com/#docs/guide/b4d66ebee72645c1a3501a769e935541.html

上的OpenUI5教程

现在"步骤7"我在加载应用时遇到错误:

failed to load 'sap/m/splitApp.js' from resources/sap/m/splitApp.js: 404 - Resource could not be found!

UIComponent.js抛出错误消息,这是来自UI5库的文件,这意味着找到了库本身。

请帮忙。

代码是教程的精确副本,项目由Eclipse和UI5插件创建。

<!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.m"
            data-sap-ui-theme="sap_bluecrystal"
            data-sap-ui-xx-bindingSyntax="complex"
            data-sap-ui-resourceroots='{
                "sap.ui.demo.tdg": "./"
            }'>
    </script>
    <!-- only load the mobile lib "sap.m" and the "sap_bluecrystal" theme -->

    <script>
        sap.ui.getCore().attachInit(function() {
            new sap.m.Shell({
                app: new sap.ui.core.ComponentContainer({
                    height : "100%",
                    name : "sap.ui.demo.tdg"
                })
            }).placeAt("content");
        });
    </script>

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

Component.js

jQuery.sap.declare("sap.ui.demo.tdg.Component");
jQuery.sap.require("sap.ui.demo.tdg.MyRouter");

sap.ui.core.UIComponent.extend("sap.ui.demo.tdg.Component", {
 metadata : {
 name : "TDG Demo App",
 version : "1.0",
 includes : [],
 dependencies : {
  libs : ["sap.m", "sap.ui.layout"],
  components : []
 },
 rootView : "sap.ui.demo.tdg.view.App",
 config : {
  resourceBundle : "i18n/messageBundle.properties",
  serviceConfig : {
   name : "Northwind",
   serviceUrl : "http://services.odata.org/V2/(S(sapuidemotdg))/OData/OData.svc/"
  }
 },
 routing : {
   config : {
    routerClass : sap.ui.demo.tdg.MyRouter,
    viewType : "XML",
    viewPath : "sap.ui.demo.tdg.view",
    targetAggregation : "detailPages",
    clearTarget : false
   },
  routes : [
   {
    pattern : "",
    name : "main",
    view : "Master",
    targetAggregation : "masterPages",
    targetControl : "idAppControll",
    subroutes : [
           {
                                        pattern : "{product}/:tab:",
                                        name : "product",
                                        view : "Detail"
                                    }
                                  ]
                  },
                  {
                      name : "catchallMaster",
                      view : "Master",
                      targetAggregation : "masterPages",
                      targetControl : "idAppControl",
                      subroutes : [
                                    {
                                        pattern : ":all*:",
                                        name : "catchallDetail",
                                        view : "NotFound"
                                    }
                                  ]
                  }
                 ]
    }
},

    init : function() {
    sap.ui.core.UIComponent.prototype.init.apply(this, arguments);

    var mConfig = this.getMetadata().getConfig();

    var rootPath = jQuery.sap.getModulePath("sap.ui.demo.tdg");

    var i18nModel = new sap.ui.model.resource.ResourceModel({
        bundleUrl : [rootPath, mConfig.resourceBundle].join("/")
    });
    this.setModel(i18nModel, "i18n");

    var sServiceUrl = mConfig.serviceConfig.serviceUrl;
    var oModel = new sap.ui.model.odata.ODataModel(sServiceUrl, true);
    this.setModel(oModel);

    var deviceModel = new sap.ui.model.json.JSONModel({
        isTouch : sap.ui.Device.support.touch,
        isNoTouch : !sap.ui.Device.support.touch,
        isPhone : sap.ui.Device.system.phone,
        isNoPhone : !sap.ui.Device.system.phone,
        listMode : sap.ui.Device.system.phone ? "None" : "SingleSelectMaster",
        listItemType : sap.ui.Device.system.phone ? "Active" : "Inactive"
    });
    deviceModel.setDefaultBindingMode("OneWay");
    this.setModel(deviceModel, "device");

    this.getRouter().initialize();
},

});

MyRouter.js

jQuery.sap.require("sap.m.routing.RouteMatchedHandler");
jQuery.sap.require("sap.ui.core.routing.Router");
jQuery.sap.declare("sap.ui.demo.tdg.MyRouter");

sap.ui.core.routing.Router.extend("sap.ui.demo.tdg.MyRouter", {

constructor : function() {
    sap.ui.core.routing.Router.apply(this, arguments);
    this._oRouteMatchedHandler = new sap.m.routing.RouteMatchedHandler(this);
},

myNavBack : function(sRoute, mData) {
    var oHistory = sap.ui.core.routing.History.getInstance();
    var sPreviousHash = oHistory.getReviousHash();

    if(sPreviousHash !== undefined) {
        window.history.go(-1);
    } else {
        var bReplace = true;
        this.navTo(sRoute, mData, bReplace);
    }
},

myNavToWithoutHash : function (oOptions) {
    var oSplitApp = this._findSplitApp(oOptions.currentView);

    var oView = this.getView(oOptions.targetView, oOptions.targetViewType);
    oSplitApp.addPage(oView, oOptions.isMaster);
    oSplitApp.to(oView.geId(), oOptions.transition || "show", oOptions.data);
},

backWithouHash : function (oCurrentView, bIsMaster) {
    var sBackMethod = bIsMaster ? "backMaster" : "backDetail";
    this._findSplitApp(oCurrentView)[sBackMethod]();
},

destroy : function (oControl) {
    sap.ui.core.routing.Router.prototype.destroy.apply(this, arguments);
    this._oRouteMatchedHandler.destroy();
},

_findSplitApp : function (oControl) {
    sAncestorControlName = "idAppControl";

    if (oControl instanceof sap.ui.core.mvc.View & oControl.byId(sAncestorControlName)){
        return oControl.byId(sAncestorConrolName);
    }

    return oControl.getParent() ? this._findSplitApp(oControl.getParent(), sAncestorControlName) : null;
}

 });

1 个答案:

答案 0 :(得分:0)

这是一个拼写错误。 Thx to Qualiture