routes - SAPUI5 路由 - 无法找到 ID 为 idAppControl 的控件

标签 routes aggregation deep-linking sapui5

首先,我知道有类似的问题,但没有一个答案可以解决我的问题。

简要查看我的代码:

我的 Component.js 看起来像这样

routes: [
            {
                pattern: "",                //home page
                name: util.Constants.Tile,
                view: util.Constants.Tile,
                viewId: util.Constants.Tile,
                targetAggregation: "pages"
                //targetControl: "idAppControl"
            },
            {
                pattern: "firstExample",
                name: util.Constants.FirstExample,
                view: util.Constants.FirstExample,
                viewId: util.Constants.FirstExample,
                targetAggregation: "pages",
                targetControl : "idAppControl",
                subroutes : [
                    {
                        pattern: "firstExample",
                        name: util.Constants.ExampleMaster,
                        view: util.Constants.ExampleMaster,
                        targetAggregation: "masterPages",
                        targetControl: "idSplitContainerControl",
                    },
                    {
                        pattern: "firstExample/:typeMaster:",
                        name: util.Constants.ExampleSecondMaster,
                        view: util.Constants.ExampleSecondMaster,
                        targetAggregation: "masterPages",
                        targetControl: "idSplitContainerControl",
                        subroutes : [
                            {
                                pattern : "firstExample/:typeDetail:",
                                name : util.Constants.ExampleDetail,
                                view : util.Constants.ExampleDetail,
                                targetAggregation : "detailPages"
                            }
                        ]
                    }
                ]
            },

简短说明:这是一个具有普通应用程序 View (无主视图)和一个带有两个主视图和一个详细 View 的后续 SplitContainer 的页面。每当我想调用详细 View 时

onSelect : function (e) {
    var routeTo = e.getSource().getTitle();

    this.router.navTo(util.Constants.ExampleDetail, { typeDetail : routeTo } );

},

它说

2015-03-30 14:50:06 Control with ID idAppControl could not be found - sap-ui-core-dbg.js:15213

有什么想法吗? 提前感谢您的帮助!

<小时/>

类似主题的链接:

最佳答案

调试别人的路由代码很困难,所以这是我的多页面应用程序的工作路由器。第一个是带有图 block 的简单页面,第二个是主/详细 View 。

routes : [
    {
        pattern : "",
        name: "launchpad",
        view: "Launchpad",
        targetControl: "masterView"
    },
    {
        pattern : "split",
        name: "app",
        view: "App",
        targetControl: "masterView",
        subroutes : [
            {
                pattern : "master",
                name : "main",
                // placed in master masterPages aggregation of splitapp
                view : "Master",
                targetAggregation : "masterPages",
                targetControl : "idAppControl",
                // places detail in detailPages aggreg. of the splitapp
                subroutes : [
                    {
                        // product context is expected
                        // and which tab should be selected (supplier/category)
                        pattern : "{product}/:tab:",
                        name : "product",
                        view : "Detail",
                        targetAggregation :  "detailPages"
                    }
                ]
            }
        ]
    },
    // catchall routes, to show not found message, when route is not valid
    {
        name : "catchallMaster",
        view : "Master",
        targetAggregation : "masterPages",
        targetControl : "idAppControl",
        subroutes : [
            {
                pattern : ":all*:",
                name : "catchallDetail",
                view : "NotFound"
            }
        ]
    }
]
}
// custom routing is performed in MyRouter.js
},

请注意,两个路由都设置了 targetControl。 masterView 是首先加载的 MasterApp 的一部分。

<mvc:View
    xmlns:mvc="sap.ui.core.mvc"
    displayBlock="true"
    xmlns="sap.m">
    <App
        id="masterView">
    </App>
</mvc:View>

idAppControl 是 App.view.xml 的一部分,其中 <SplitApp id="idAppControl" /> 。就像您一样,我的应用程序基于开发人员指南中的示例。

Component.js 有这个:

createContent: function() {
    var viewData = {
        component:this
    };
    return sap.ui.view({
        viewName: "sap.ui.demo.app.view.MasterApp",
        type: sap.ui.core.mvc.ViewType.XML,
        viewData: viewData
    });
}

应用程序 View :

<mvc:View
    xmlns:mvc="sap.ui.core.mvc"
    displayBlock="true"
    xmlns="sap.m">
    <SplitApp id="idAppControl" />
</mvc:View>

配置:

routing: {
    config: {
        // custom router class
        routerClass : sap.ui.demo.app.MyRouter,
        // xml views
        viewType : "XML",
        // absolute path to views
        viewPath : "sap.ui.demo.app.view",
        // unless stated otherwise, router places view in detail part
        targetAggregation : "pages",
        // don't clear the detail pages before views are added
        clearTarget : false
    },
}

当查看您的路由器时,我会说您的页面顺序有问题。作为一般建议,我想说 navTo 采用路线的参数“名称”,而不是 View 或模式。我花了一些时间才了解这一点。

亲切的问候,

迈克尔

关于routes - SAPUI5 路由 - 无法找到 ID 为 idAppControl 的控件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29348478/

相关文章:

java - 关联、组合和聚合 - 用 java 实现

cordova - 添加深层链接到 cordova 应用程序

ruby-on-rails - 更改 shopify_app gem 的引擎路由

ruby-on-rails - 用于创建方法 smart_listing 的 Rails 嵌套路由

c# - 聚合和 DDD

node.js - Elasticsearch 对部分字符串而非完整字符串进行聚合

r - 多条路线的行驶距离

ruby-on-rails - 命名空间、静态页面和继承的 Controller ,什么文件夹中的什么文件?

android - Android 中的延迟深度链接 URL

react-native - 如何在react-native中在外部播放器中打开视频网址