gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 09:48:02 27 4
gpt4 key购买 nike

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

我使用 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" />

名为“list.html”的列表组件的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/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com