【问题标题】:How to use children editor on a list component's dialog on AEM?如何在 AEM 的列表组件对话框中使用子编辑器?
【发布时间】:2020-05-27 20:19:16
【问题描述】:

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

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

我能做什么?

【问题讨论】:

  • 能写出你使用的AEM版本和核心组件吗?
  • 我使用 AEM 6.5,并且 sling:resourceSuperType 是核心列表。

标签: aem aem-core-wcm-components


【解决方案1】:

这不起作用,因为负责更新数据的 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(注册到您自己定义的选择器)与核心组件相同。

希望对你有帮助!

【讨论】:

  • 手风琴和tab怎么会有童工编辑?其背后的机制是什么?
  • 这些都是基于相同的逻辑。请仔细看我上面所说的servlet代码,资源类型在那个servlet实现中已经提到了。
【解决方案2】:

这是 AEM 6.5 上的一个错误,团队正在努力解决。

https://github.com/adobe/aem-core-wcm-components/issues/985

【讨论】:

  • 这根本不是一个错误,正如它所说的那样,请不要用虚假信息混淆其他人。
  • @Pakira 你可以向下滚动到 msagolj 发表的评论
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-11-09
相关资源
最近更新 更多