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

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

问题描述

我对Alfresco Aikau非常陌生,但是我不了解有效负载的工作原理。有很多使用有效负载的示例,但我没有进行连接。



我似乎发现的所有示例都暗示(对我而言)有效载荷用于定义将要加载并返回到小部件的数据列表。 / p>

但是,数据列表似乎总是一个url,我认为该url的结果是一个json对象。



如果我想调用一个构建json对象并将其返回给小部件的webscript,该怎么办?其机制是什么?我应该将其加载到有效载荷中吗?



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



谢谢

解决方案

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



回答您的特定问题-a列表包中的窗口小部件(最基本的是alfresco / lists / AlfList)将发布有效负载,请求加载数据。列表可以与任何服务一起使用,因此发布的主题将取决于您希望使用的服务而有所不同,同样,发布的有效负载也将有所不同。



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



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



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



Aikau教程完成了创建使用列表并加载列表数据的页面的过程(来自各种来源)-如果您还没有的话,我建议您仔细阅读本教程。



也可以使用数据初始化列表(通过 currentData属性),这样您就无需对数据进行XHR请求。

p>

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.

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

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.

Thanks

解决方案

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.

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.

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.

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).

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).

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.

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天全站免登陆