简体   繁体   English

SAP UI5应用程序-方法

[英]SAP UI5 Application - Method

this.getModel.metadataLoaded() this.getModel.metadataLoaded()

What is the main purpose of using this metadataLoaded? 使用此metadataLoaded的主要目的是什么?

What are the advantage and disadvantage of metadataLoaded? metadataLoaded的优缺点是什么?

Metadata is the information about the oData service itself. 元数据是有关oData服务本身的信息。 It contains entity, entityset, association information, field labels and all the other configuration it needs. 它包含实体,实体集,关联信息,字段标签以及它需要的所有其他配置。 The oData model uses it, smart controls are built on top of it. oData模型使用它,在其之上构建智能控件。 You'll find calls to fetch this at the start of every application (look for $metadata in the console of the browser). 您会在每个应用程序的开头找到调用此操作的调用(在浏览器的控制台中查找$metadata )。 Before this is loaded, you can't use the service. 在加载此服务之前,您无法使用该服务。 In most cases this will be ready before your view is displayed. 在大多数情况下,这将在显示视图之前准备就绪。

metadataLoaded() returns a promise you can use to do things if you want to make certain that the service is ready, like: 如果要确定服务已准备就绪, metadataLoaded()将返回一个可用于执行操作的承诺,例如:

this.getModel().metadataLoaded().then(_ => {
  //use the service here to load some data
  this.getView().bindElement({
    path: `/PathToMyEntitySet('Key')`,
    events: {
      dataRequested: _ => this.getView().setBusy(true),
      dataReceived: data => console.log(data),
      change: _ => this.getView().setBusy(false)
    }
  });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM