SAPUI5路由

编程入门 行业动态 更新时间:2024-10-08 07:37:38
本文介绍了SAPUI5路由-找不到ID为idAppControl的控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

first at all, I´m aware that there were similiar asked questions, but none of the answers could solve my problem.

简短地查看我的代码:

我的Component.js如下

My Component.js looks like this

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" } ] } ] },

简短说明:这是一个具有常规应用程序视图(无主视图)的页面,其后的SplitContainer具有两个主视图和一个详细信息视图。每当我想调用详细信息视图

Short explanation: It´s a page with a normal app view (no master view) and a following SplitContainer with two master and one detail view. Whenever I want to call the detail view

onSelect : function (e) { var routeTo = e.getSource().getTitle(); this.router.navTo(util.Constants.ExampleDetail, { typeDetail : routeTo } ); },

它说

2015-03-30 14:50:06找不到ID为idAppControl的控件-sap-ui-core-dbg.js:15213

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

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

Any idea? Thanks for your help in advance!

指向相似主题的链接:

  • stackoverflow/questions/29003071/ui5-cant-find-a-control-via-its-id# =
  • SAPUI5路由引发错误控件(应用程序控件的ID)没有称为页面的聚合
  • stackoverflow/questions/29003071/ui5-cant-find-a-control-via-its-id#=
  • SAPUI5 routing throws error "Control (ID of an App control) does not has an aggregation called pages"
推荐答案

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

it's difficult to debug the routing code of someone else, so here is my working router for a multi page application. The first one is a simple page with tiles and the second one is a Master/Detail 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 },

$中执行b $ b

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

Note that the targetControl is set for both routes. masterView is part of the MasterApp that is loaded first.

<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 /> 。就像您一样,我也是基于开发人员指南中的示例创建应用程序的。

idAppControl is part of the App.view.xml with <SplitApp id="idAppControl" />. I based my application on the example in the developer guidelines just like you.

Component.js具有以下功能:

Component.js has this:

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 }); }

App.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接受路由的参数名称,而不是视图或模式。花了我些时间来学习。

When looking at your router, I would say you have problems with the order of the pages. And as general advise, I would like to say that navTo takes the parameter "name" of the routes, not view or pattern. Took me some time to learn that.

亲切的问候,

Michael

更多推荐

SAPUI5路由

本文发布于:2023-11-22 08:08:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1616617.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:路由

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!