如何在AEM上的列表组件对话框上使用子级编辑器?

问题描述 投票:2回答:1

我正在尝试在列表组件的对话框上启用子级编辑器,以允许用户向其中添加自定义组件,例如来自核心的轮播组件。

我使用AEM 6.5,并且sling:resourceSuperType是来自核心的列表。

该组件的My.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从轮播移动到我的列表组件。但是,它没有解决问题。

我该怎么办?

aem aem-core-wcm-components
1个回答
2
投票

这不起作用,因为负责更新数据的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

如您所见,发送了选择器container并使其成为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

  1. 创建与此相同的自定义客户端库:

    / apps / core / wcm / components / commons / editor / dialog / childreneditor / v1 / childreneditor / clientlibs

但是更改var POST_SUFFIX =“ .container.html”;到您自己的选择器

然后创建与核心组件相同的自己的servlet(注册到自己定义的选择器)。

希望有帮助!

© www.soinside.com 2019 - 2024. All rights reserved.