具有多个参数的Fiori Master Detail App路由

问题描述 投票:0回答:1

我目前正在开发我的第一个SAP Fiori App。在SAP WebIDE中,我使用Master Detail从模板创建了一个项目,并与oData Service连接。

如果我运行未修改的应用程序,则所有工作正常,除了没有数据加载到详细信息视图上,因为oData服务需要2个参数来获得唯一记录。

现在的问题是,如果我将应用程序修改为使用2个参数并导航到详细视图,则详细视图会加载,但甚至不会打oData服务。 (Chrome开发工具中没有$ batch请求)

manifest.json中的修改

    {
        "pattern": "JOBSSet/{Jobname}/{Jobcount}",
        "name": "object",
        "target": [
        "master",
        "object"
        ]
    }

主控制器的修改:

    _showDetail : function (oItem) {
            var bReplace = !Device.system.phone;
            // set the layout property of FCL control to show two columns
            this.getModel("appView").setProperty("/layout", "TwoColumnsMidExpanded");
            this.getRouter().navTo("object", {
                Jobname : encodeURIComponent(oItem.getBindingContext().getProperty("Jobname")),
                Jobcount : oItem.getBindingContext().getProperty("Jobcount")
            }, bReplace);
        }

详细控制器的修改:

_onObjectMatched : function (oEvent) {

            var sJobname =  decodeURIComponent(oEvent.getParameter("arguments").Jobname);
            var sJobcount =  oEvent.getParameter("arguments").Jobcount;

            this.getModel("appView").setProperty("/layout", "TwoColumnsMidExpanded");
            this.getModel().metadataLoaded().then( function() {
                var sObjectPath = this.getModel().createKey("JOBSSet", {
                    Jobname :  sJobname,
                    Jobcount : sJobcount
                });
                this._bindView("/" + sObjectPath);

            }.bind(this));
        }
odata sapui5 sap-fiori
1个回答
0
投票

仅当您从其首页开始运行该应用程序时,才会发生此行为。

[例如,如果您在智能手机上测试应用程序(或使用Chrome Dev Tools进行模拟),您会看到直接将应用程序打开到详细信息页面时,将会有一个网络呼叫来获取项目详细信息。也将是$ batch调用,但在其中将找到'GET / JOBSSet(Jobname ='x',Jobcount ='y')。

基本上会发生以下情况:默认情况下,UI5将数据缓存在Context对象中(假设您正在使用v2.ODataModel类)。当您运行该应用程序并看到“作业”列表时,该库已经为从oData服务返回的每条记录创建了一个Context对象。

[如果稍后在应用程序中创建Context对象(直接或间接地,例如bindElement方法,则UI5将检查给定的路径-/JOBSSet(Jobname='x',Jobcount='y')。如果已经有与该路径链接的上下文,则该上下文应该已经存在于主存储器中。因此,不需要额外的呼叫。

© www.soinside.com 2019 - 2024. All rights reserved.