2017-07-13 78 views
0

所以我試圖重新此應用對SAP的Web IDE:錯誤一MasterDetail頁

app

但我不斷收到此錯誤

enter image description here

這是我的App.Controller.js代碼:

sap.ui.define([ 
    "pt/procensus/ui5rv/controller/BaseController", 
    "sap/ui/model/json/JSONModel" 
], function (BaseController, JSONModel) { 
    "use strict"; 

    return BaseController.extend("pt.procensus.ui5rv.controller.App", { 

     onInit : function() { 
      var oViewModel, 
       fnSetAppNotBusy, 
       oListSelector = this.getOwnerComponent().oListSelector, 
       iOriginalBusyDelay = this.getView().getBusyIndicatorDelay(); 

      oViewModel = new JSONModel({ 
       busy : true, 
       delay : 0 
      }); 
      this.setModel(oViewModel, "appView"); 

      fnSetAppNotBusy = function() { 
       oViewModel.setProperty("/busy", false); 
       oViewModel.setProperty("/delay", iOriginalBusyDelay); 
      }; 


      this.getOwnerComponent().oWhenMetadataIsLoaded. 
       then(fnSetAppNotBusy, fnSetAppNotBusy); 

      // Makes sure that master view is hidden in split app 
      // after a new list entry has been selected. 
      oListSelector.attachListSelectionChange(function() { 
       this.byId("idAppControl").hideMaster(); 
      }, this); 

      // apply content density mode to root view 
      this.getView().addStyleClass(this.getOwnerComponent().getContentDensityClass()); 
     } 

    }); 

} 
); 

這是我的Base.Controller.js代碼:

/*global history */ 
sap.ui.define([ 
"sap/ui/core/mvc/Controller", 
"sap/ui/core/routing/History" 
], function(Controller, History) { 
"use strict"; 

return Controller.extend("pt.procensus.ui5rv.controller.BaseController", { 
    /** 
    * Convenience method for accessing the router in every controller of the application. 
    * @public 
    * @returns {sap.ui.core.routing.Router} the router for this component 
    */ 
    getRouter: function() { 
     return this.getOwnerComponent().getRouter(); 
    }, 

    /** 
    * Convenience method for getting the view model by name in every controller of the application. 
    * @public 
    * @param {string} sName the model name 
    * @returns {sap.ui.model.Model} the model instance 
    */ 
    getModel: function(sName) { 
     return this.getView().getModel(sName); 
    }, 

    /** 
    * Convenience method for setting the view model in every controller of the application. 
    * @public 
    * @param {sap.ui.model.Model} oModel the model instance 
    * @param {string} sName the model name 
    * @returns {sap.ui.mvc.View} the view instance 
    */ 
    setModel: function(oModel, sName) { 
     return this.getView().setModel(oModel, sName); 
    }, 

    /** 
    * Convenience method for getting the resource bundle. 
    * @public 
    * @returns {sap.ui.model.resource.ResourceModel} the resourceModel of the component 
    */ 
    getResourceBundle: function() { 
     return this.getOwnerComponent().getModel("i18n").getResourceBundle(); 
    }, 

    /** 
    * Event handler for navigating back. 
    * It checks if there is a history entry. If yes, history.go(-1) will happen. 
    * If not, it will replace the current entry of the browser history with the master route. 
    * @public 
    */ 
    onNavBack: function() { 
     var sPreviousHash = History.getInstance().getPreviousHash(); 

     if (sPreviousHash !== undefined) { 
      // The history contains a previous entry 
      history.go(-1); 
     } else { 
      // Otherwise we go backwards with a forward history 
      var bReplace = true; 
      this.getRouter().navTo("master", {}, bReplace); 
     } 
    } 

}); 

}); 

我的應用程序文件夾:

enter image description here

而且我不明白這是爲什麼發生。我已經刪除「然後」的一部分,它給了我更多的錯誤...:/

任何幫助將是非常讚賞:)

回答

0

你可以試試這個?至少,這是它如何工作的我App.controller:

this.getOwnerComponent().getModel().metadataLoaded() 
      .then(fnSetAppNotBusy, fnSetAppNotBusy); 
+0

它didn't工作。該錯誤消息「無法讀取屬性‘’的未定義」 –

+0

metadataLoaded能否請您發表您的基本控制器代碼? –

+0

當然可以。 –