2016-03-23 8 views
0

分割アプリでは、詳細ビューはどのモデルにもバインドしません。 component.jsモデルなしの分割アプリの詳細ページ

私はこのような名前のモデルをインスタンス化:

// creation and setup of the oData model 
var oConfig = { 
    metadataUrlParams: {}, 
    json: true, 
    defaultBindingMode : "TwoWay", 
    defaultCountMode : "Inline", 
    useBatch : false 
} 

// ### tab-employee ### 
var oModelEmpl = new sap.ui.model.odata.v2.ODataModel("/sap/opu/odata/sap/EMP_SRV"), oConfig); 

oModelEmpl.attachMetadataFailed(function() { 
    this.getEventBus().publish("Component", "MetadataFailedEMPL"); 
}, this); 

this.setModel(oModelEmpl, "EMPL"); 

デア・マスター・ビューコントローラのメソッドonSelectは、リストアイテムをクリックすることで起動されます。

onSelect: function(oEvent) {       
    this.showDetail(oEvent.getParameter("listItem") || oEvent.getSource()); 
    } 

これは私がバインドを更新するためのこれらの2つの方法をした詳細ビューのコントローラでshowDetail

showDetail: function(oItem) { 
    var bReplace = jQuery.device.is.phone ? false : true; 
    this.getRouter().navTo("detail", { 
     from: "master", 
     entity: oItem.getBindingContext('EMPL').getPath().substr(1), 
    }, bReplace); 
}, 

メソッドを呼び出します。 onRouteMatchedは、というエラーメッセージが表示されるbindViewを呼び出します。

onRouteMatched: function(oEvent) { 
    var oParameters = oEvent.getParameters(); 

    jQuery.when(this.oInitialLoadFinishedDeferred).then(jQuery.proxy(function() { 
     var oView = this.getView(); 

     if (oParameters.name !== "detail") { 
      return; 
     } 

     var sEntityPath = "/" + oParameters.arguments.entity; 
      this.bindView(sEntityPath); 
     }, this)); 
}, 



bindView: function(sEntityPath) { 
    var oView = this.getView();    
    oView.bindElement(sEntityPath); 


    //Check if the data is already on the client 
    if (!oView.getModel().getData(sEntityPath)) { 
     // Check that the entity specified was found. 
     oView.getElementBinding().attachEventOnce("dataReceived", jQuery.proxy(function() { 
     var oData = oView.getModel().getData(sEntityPath); 
      if (!oData) { 
       this.showEmptyView(); 
       this.fireDetailNotFound(); 
      } else { 
       this.fireDetailChanged(sEntityPath); 
      } 
     }, this)); 

    } else { 
     this.fireDetailChanged(sEntityPath); 
    } 
}, 

私はこの分割アプリケーションをWebIDEによって生成されたテンプレートに対して実装しようとしました。何が欠けているのか?

答えて

0

あなたが書いたように、名前が"EMPL"の「名前付きモデル」を作成しています。あなたがモデルを取得するために同じ名前を使用する必要がコントローラで

:同様に

this.getView().getModel("EMPL"); 

bindElement()を呼び出すときにモデル名与えることがあります。

// Assuming sEntityPath = "/items/0" 
this.getView().bindElement("EMPL>" + sEntityPath); 
+0

ルックスを「日常的な盲目的」のように...ありがとう! – srz