2016-11-14 37 views
0

我一直在試圖網頁添加到從自己的驅動程序的其他視圖(view.js)我SplitApp,但這樣做會導致以下錯誤:配置路由在SplitApp SAPUI5顯示頁

Sap-ui-core.js: 174 Uncaught Error: failed to load 'view/GestionDePlanta.view.js' from openui5-1.40.8/resources/view/GestionDePlanta.view.js: 404 - Not Found (...) 

我認爲它與啓動時訪問該視圖的路徑有關

Sap.ui.view ({id: "GestionDePlanta", viewName: "view.GestionDePlanta", type: sap.ui.core.mvc.ViewType.JS}); 

任何人都知道任何方式來做到這一點?

我下面的教程,我發現很容易理解,但顯然這是不完整的: http://blog.mypro.de/2014/02/14/add-page-to-ui5-boilerplate/

太謝謝你了。

的index.html

<!DOCTYPE HTML> 
<html> 

    <head> 
     <meta http-equiv="X-UA-Compatible" content="IE=edge" /> 
     <meta charset="UTF-8"> 

     <title>DatosMaestros</title> 

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

     <link rel="stylesheet" type="text/css" href="css/style.css"> 

     <script type="text/javascript" src="js/utilityFunction.js"></script> 
     <script type="text/javascript" src="js/xml2json.js"></script> 

     <script> 
       sap.ui.localResources("P_GestionDePlanta"); 

     var url = "http://services.odata.org/V4/Northwind/Northwind.svc/Employees", 
      oModel = new sap.ui.model.json.JSONModel(url, true); 

     sap.ui.getCore().setModel(oModel); 

     var app = new sap.m.SplitApp("appId",{mode:sap.m.SplitAppMode.ShowHideMode}); 
     var master = sap.ui.view({id:"GestionDePlanta", viewName:"view.GestionDePlanta", type:sap.ui.core.mvc.ViewType.JS}); 
     app.addMasterPage(master); 
     var detail = sap.ui.view({id:"PlanAbastecimiento", viewName:"view.PlanAbastecimiento", type:sap.ui.core.mvc.ViewType.JS}); 
     app.addDetailPage(detail); 
     app.placeAt("content"); 

     </script> 
    </head> 

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

</html> 

Component.js

sap.ui.define([ 
    "sap/ui/core/UIComponent", 
    "sap/ui/Device", 
    "P_GestionDePlanta/model/models" 
], function(UIComponent, Device, models) { 
    "use strict"; 

    return UIComponent.extend("P_GestionDePlanta.Component", { 

     metadata: { 
      manifest: "json" 
     }, 

     /** 
     * The component is initialized by UI5 automatically during the startup of the app and calls the init method once. 
     * @public 
     * @override 
     */ 
     init: function() { 
      // call the base component's init function 
      UIComponent.prototype.init.apply(this, arguments); 

      // set the device model 
      this.setModel(models.createDeviceModel(), "device"); 
     } 
    }); 
}); 

Manifiest.json

{ 
    "_version": "1.1.0", 
    "sap.app": { 
     "_version": "1.1.0", 
     "id": "P_GestionDePlanta", 
     "type": "application", 
     "i18n": "i18n/i18n.properties", 
     "applicationVersion": { 
      "version": "1.0.0" 
     }, 
     "title": "{{appTitle}}", 
     "description": "{{appDescription}}", 
     "sourceTemplate": { 
      "id": "ui5template.basicSAPUI5ApplicationProject", 
      "version": "1.32.0" 
     } 
    }, 

    "sap.ui": { 
     "_version": "1.1.0", 
     "technology": "UI5", 
     "icons": { 
      "icon": "", 
      "favIcon": "", 
      "phone": "", 
      "[email protected]": "", 
      "tablet": "", 
      "[email protected]": "" 
     }, 
     "deviceTypes": { 
      "desktop": true, 
      "tablet": true, 
      "phone": true 
     }, 
     "supportedThemes": [ 
      "sap_hcb", 
      "sap_bluecrystal" 
     ] 
    }, 

    "sap.ui5": { 
     "_version": "1.1.0", 
     "rootView": { 
      "viewName": "P_GestionDePlanta.view.GestionDePlanta", 
      "type": "JS" 
     }, 
     "dependencies": { 
      "minUI5Version": "1.30.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": "P_ProcesamientoDeArchivos.i18n.i18n" 
       } 
      } 
     }, 
     "resources": { 
      "css": [{ 
       "uri": "css/style.css" 
      }] 
     } 
    } 
} 

個文件夾

Image:

+0

好吧,這不是」即使你遵循教程,你也不知道該怎麼說。在教程中有什麼你不明白的東西?你被阻止的東西?我沒有看到任何問題可以在這裏回答。 –

+0

我已經看到了幾種方式來做到這一點,但我離開的教程,我找到了最簡單的方法,但仍然無法將視圖添加到我的分割中。那是我的「封鎖」 –

+0

好的,歡迎來到SO。你需要學會正確地提出問題。我無法做出你的問題的頭部或尾部,或不存在。編輯它;儘可能清楚地說明,詳細說明你的嘗試,以及你的阻擋者是什麼。 –

回答

0

那麼該教程,你跟着是相當過時。你會想要使用基於組件的結構(你在你的示例中有一個組件,但從不使用它)。官方SAPUI5/OpenUI5開發人員指南特別是演練大多是最新的。我建議你在那裏做walkthrough

回到您的問題:UI5有自己的方式來從名稱解析模塊(≈javascript文件)。

在你的例子中,你給UI5一個視圖的名字:"view.GestionDePlanta"查看是命名空間和GestionDePlanta是模塊名稱。因此,UI5查找名稱空間視圖並且 - 缺少任何匹配的名稱空間路徑映射 - 默認使用與您在引導程序<script>元素中定義的sap-ui-core.js相同的路徑的UI5框架本身:./openui5-1.40.8/resources/view

要添加這樣的名稱空間路徑映射,您可以使用sap.ui.localResources()函數。

使用您的sap.ui.localResources("P_GestionDePlanta");聲明,UI5將在文件夾./P_GestionDePlanta/view中查找模塊"P_GestionDePlanta.view.GestionDePlanta"

那是好多了,但你的文件夾結構應該是這樣的,那麼:

+ P_GestionDePlanta 
    + view 
     GestionDePlanta.view.js 
    + controller 
     GestionDePlanta.controller.js 
index.html 

的另一種方式是使用jQuery.sap.registerModulePath()增加一個命名空間的路徑映射。使用jQuery.sap.registerModulePath("P_GestionDePlanta", "./"); UI5將在文件夾./view中查找模塊"P_GestionDePlanta.view.GestionDePlanta"

有了,你可以保持您的文件夾結構:

+ view 
    GestionDePlanta.view.js 
+ controller 
    GestionDePlanta.controller.js 
index.html 

但無論哪種方式,你必須與P_GestionDePlanta提供完整的命名空間開始無處不在,像這樣:

sap.ui.view({id:"GestionDePlanta", viewName:"P_GestionDePlanta.view.GestionDePlanta", type:sap.ui.core.mvc.ViewType.JS});