拆分应用,而无需模型的详细信息页 [英] Detail page of split app without model

查看:269
本文介绍了拆分应用,而无需模型的详细信息页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序拆分的细节视图不绑定任何模型。

In my split app the detail view does not bind any model.

component.js 我实例化一个名为模型是这样的:

In the component.js I instantiate a named model like this:

// 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");

在DER主视图控制器的方法 ONSELECT 通过点击一个列表项被解雇了。

The method onSelect in der master-view controller is fired by clicking on an listitem.

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

这将调用方法 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 ,在那里我得到的错误消息类型错误:oView.getModel(。 ..)未定义

In the controller of the detail-view I've these two methods for updating the binding. onRouteMatched calls bindView, where I get the error-message TypeError: oView.getModel(...) is undefined.

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生成的模板应用程序。任何想法缺什么?

I've tried to implement this split app relative to the template generated by WebIDE. Any idea what is missing?

推荐答案

你自己写,你正在创建一个命名模式的名称EMPL

As you wrote yourself, you are creating a "named Model" with the name "EMPL".

在控制器,你必须使用相同的名称,以获得型号:

In the Controller you have to use the same name to get the Model:

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


打电话时同样 bindElement()你必须给型号名称:

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

这篇关于拆分应用,而无需模型的详细信息页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆