Aikau 基础知识 - 有效载荷 101 [英] Aikau fundamentals - payload 101

查看:36
本文介绍了Aikau 基础知识 - 有效载荷 101的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 Alfresco Aikau 很陌生,我只是不明白有效载荷的工作原理.有很多使用有效载荷的例子,但我没有建立连接.

I am very new to Alfresco Aikau and I just don't get how payload works. There are many examples where payload is used but I am not making the connection.

我似乎找到的所有示例都表明(对我来说是这样)有效载荷用于定义将加载并返回到小部件的数据列表.

All the examples I seem to find suggest (to me that is) that the payload is used to define a data list that will be loaded and returned to the widget.

但是,数据列表似乎总是一个 url,我假设 url 的结果是一个 json 对象.

But, the data list always seems to be a url and I assume the result from the url is a json object.

如果我想调用一个 webscript 来构建一个 json 对象并将它返回给小部件怎么办.这样做的机制是什么?我是否将其加载到有效负载中?如果是,如何加载?

What if I want to call a webscript that build a json object and returns it back to the widget. What would be the mechanism for that? Do I load it into the payload and if so how?

希望您能理解我的困惑,并为我指明正确的方向.

Hopefully you understand my confusion and can point me in the right direction.

谢谢

推荐答案

Aikau 使用发布/订阅模型来完全解耦所有小部件和服务.有效负载"是在主题上发布并由订阅者使用的对象.没有单一的有效载荷类型,每个小部件和服务可能期望包含不同数据的不同有效载荷.我们一直在研究开箱即用的小部件使用的所有主题,并将它们移至常量模块和 JSDoc 用于记录每个主题的每个有效负载的结构.

Aikau uses a publication/subscription model to fully decouple all the widgets and services. A "payload" is the object that is published on a topic and consumed by the subscriber. There is no single payload type, each widget and service might be expecting different payloads containing different data. We have been working through all the topics used by widgets out-of-the-box and moving them to a constants module and the JSDoc for this documents the structure of each payload for each topic.

回答您的具体问题 - 列表包中的一个小部件(最基本的是 alfresco/lists/AlfList)将发布请求加载数据的有效负载.列表可以与任何服务一起使用,因此发布的主题将根据您希望使用的服务而有所不同,同样,发布的有效负载也会有所不同.

In answer to your specific question - a widget in the lists package (the most basic being alfresco/lists/AlfList) is going to publish a payload requesting the data to be loaded. Lists can work with any service so the topic published on will be different depending upon what service you wish to use, similarly the payload published will be different.

例如,如果您使用 CrudService,则有效负载将需要包含要加载的 URL.大多数其他服务不需要 URL,因为它们是为处理特定数据而编写的,并使用已知 URL 来检索该数据.

For example, if you're using the CrudService then the payload will need to contain the URL to load. The majority of other services won't require a URL because they are written to work with specific data and use known URLs to retrieve that data.

尽管在所有情况下都使用 CrudService 可能很诱人,但使用专用服务有很多好处 - 包括编写您自己的自定义服务 - 以便标准化返回的数据(因为许多基于 WebScript 的核心 REST API不要遵循通用模式).

Although it might be tempting to use the CrudService in all cases, there are many benefits in using dedicated services - including writing your own custom services - in order to normalize the data returned (because many of the core WebScript-based REST APIs don't follow a common schema).

当服务加载数据时,它将在响应主题上发布数据 - 发布的有效负载将包含实际列表数据.再一次, CrudService 将没有数据模式的知识",因此需要配置列表(使用itemsProperty"属性)以标识包含数据数组的有效负载中的属性,该数组表示待处理的列表渲染).

When a service has loaded the data it will publish the data on a response topic - the payload published will contain the actual list data. Once again, the CrudService will have no "knowledge" of the data schema so the list will need to be configured (using the "itemsProperty" attribute) to identify the attribute in the payload that contains the array of data that represents the list to be rendered).

GitHub 上的 Aikau 教程通过创建使用列表和加载列表数据(来自各种来源)的页面的过程 - 如果您还没有完成本教程,我建议您完成.

The Aikau tutorial on GitHub works through the process of creating pages that use lists and load list data (from a variety of sources) - I would suggest that you work through the tutorial if you haven't already.

还可以使用数据初始化列表(通过currentData"属性),这样您就不需要对数据进行 XHR 请求.

It is also possible to initialise a list with data (via the "currentData" attribute) so that you don't need to make an XHR request for data.

这篇关于Aikau 基础知识 - 有效载荷 101的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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