我正在尝试在列表组件的对话框上启用子编辑器,以允许用户向其中添加自定义组件,例如核心中的轮播组件。
我使用 AEM 6.5,并且 sling:resourceSuperType 是来自核心的列表。
我的组件的.context.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root
xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
xmlns:cq="http://www.day.com/jcr/cq/1.0"
xmlns:jcr="http://www.jcp.org/jcr/1.0"
cq:isContainer="{Boolean}true"
jcr:primaryType="cq:Component"
jcr:title="List"
sling:resourceSuperType="core/wcm/components/list/v2/list"
componentGroup="MyContent"
teaserDelegate="thisPackage/components/content/teaser/v1/teaser" />
列表组件的HTML文件名为“list.html”,如下:
<sly data-sly-use.list="com.thisPackage.aem.dna.core.models.v1.List"
data-sly-use.template="core/wcm/components/commons/v1/templates.html">
<sly data-sly-resource="${resource.path @ resourceType='wcm/foundation/components/parsys/newpar', appendPath='/*', decorationTagName='div', cssClassName='new section aem-Grid-newComponent'}"
data-sly-test="${wcmmode.edit || wcmmode.preview}">
</sly>
</sly>
我可以在编辑模式下打开组件的对话框。但是,如果我将新组件添加到对话框中的新子编辑器并尝试关闭对话框。我无法关闭对话框。 错误信息是:
org.apache.sling.api.resource.PersistenceException: Unable to commit changes to session
我按照“github.com/adobe/aem-core-wcm-components/issues/696”中的示例,并将 editConfig 从轮播移动到我的列表组件。但是,这并没有解决问题。
我能做什么?
最佳答案
这不起作用,因为负责更新数据的servlet的resourceType = core/wcm/components/carousel/v1/carousel
您可以在网络调用中看到 XHR 请求被发送到具有如下 url 的服务器:
http://localhost:4202/content/we-retail/language-masters/en/jcr:content/root/responsivegrid/carousel.container.html
正如您所看到的,选择器容器已发送并位于 servlet 之下:
https://github.com/adobe/aem-core-wcm-components/blob/master/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/servlets/ContainerServlet.java
仅监听核心组件资源类型。
在您的情况下,它是自定义组件,因此资源类型不匹配,因此您会收到错误。
有两种可能:
1:快速简单的是只需使用 sling:resourceSuperType = core/wcm/components/carousel/v1/carousel
创建与此相同的自定义客户端库:
/apps/core/wcm/components/commons/editor/dialog/childreneditor/v1/childreneditor/clientlibs
但更改 var POST_SUFFIX = ".container.html";到您自己的选择器
然后创建与核心组件相同的您自己的 servlet(注册到您自己定义的选择器)。
希望对你有帮助!
关于aem - 如何在 AEM 上的列表组件对话框中使用子编辑器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62052161/