首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在SmartEdit中的子组件中使OOTB组件属性可选?

如何在SmartEdit中的子组件中使OOTB组件属性可选?
EN

Stack Overflow用户
提问于 2020-10-26 06:11:32
回答 1查看 643关注 0票数 2

有没有办法使OOTB组件字段在SmartEdit中的子组件中可选?

例如,我通过创建子组件(例如扩展CMSParagraphComponentMyCustomParagraphComponent )来扩展CMSParagraphComponent。

OOTB CMSParagraphComponent ->内容属性是强制性的,正如其CMS结构API中所定义的那样。

代码语言:javascript
复制
<bean class="de.hybris.platform.cmsfacades.types.service.impl.DefaultComponentTypeAttributeStructure" p:typecode="CMSParagraphComponent" p:qualifier="content">
    <property name="populators">
        <set>
            <ref bean="richTextComponentTypeAttributePopulator" />
            <ref bean="requiredComponentTypeAttributePopulator" />
        </set>
    </property>
</bean>

requiredComponentTypeAttributePopulator使此属性成为强制性属性。此外,OOTB SmartEdit也使用cmsParagraphComponentValidator进行后端验证。

现在我想使属性对于我的自定义MyCustomParagraphComponent是可选的。

我尝试使用unRequiredComponentTypeAttributePopulator创建新的required=false,并将其分配给自定义组件的content属性,但这不起作用

像这样的尝试..。

代码语言:javascript
复制
<bean id="unRequiredComponentTypeAttributePopulator" class="de.hybris.platform.cmsfacades.types.populator.RequiredComponentTypeAttributePopulator">
    <property name="required" value="false" />
</bean>

<bean class="de.hybris.platform.cmsfacades.types.service.impl.DefaultComponentTypeAttributeStructure" p:typecode="PromotionalBannerComponent" p:qualifier="content">
    <property name="populators">
        <set>
            <ref bean="unRequiredComponentTypeAttributePopulator" />
        </set>
    </property>
</bean>

但这不管用。它看起来像CMS结构API只适用于那些直接分配给该组件的属性,而不是父组件。

那么,正确的方法是什么呢?

EN

回答 1

Stack Overflow用户

发布于 2022-05-23 06:59:13

在您的自定义“facade- define .xml”中,定义bean:

代码语言:javascript
复制
<bean id="optionalComponentTypeAttributePopulator"  class="de.hybris.platform.cmsfacades.types.populator.RequiredComponentTypeAttributePopulator">
    <property name="required" value="false" />
</bean>

现在,在您的自定义“facade-spring.xml.xml”中,尝试重写开箱即用的bean:

代码语言:javascript
复制
<bean class="de.hybris.platform.cmsfacades.types.service.impl.DefaultComponentTypeAttributeStructure" p:typecode="CMSLinkComponent" p:qualifier="product">
    <property name="populators">
        <set>
            <ref bean="optionalComponentTypeAttributePopulator" />
        </set>
    </property>
</bean>

我已经在本地测试过它,它运行得很好。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64532239

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档