有没有办法使OOTB组件字段在SmartEdit中的子组件中可选?
例如,我通过创建子组件(例如扩展CMSParagraphComponent的MyCustomParagraphComponent )来扩展CMSParagraphComponent。
OOTB CMSParagraphComponent ->内容属性是强制性的,正如其CMS结构API中所定义的那样。
<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属性,但这不起作用
像这样的尝试..。
<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只适用于那些直接分配给该组件的属性,而不是父组件。
那么,正确的方法是什么呢?
发布于 2022-05-23 06:59:13
在您的自定义“facade- define .xml”中,定义bean:
<bean id="optionalComponentTypeAttributePopulator" class="de.hybris.platform.cmsfacades.types.populator.RequiredComponentTypeAttributePopulator">
<property name="required" value="false" />
</bean>现在,在您的自定义“facade-spring.xml.xml”中,尝试重写开箱即用的bean:
<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>我已经在本地测试过它,它运行得很好。
https://stackoverflow.com/questions/64532239
复制相似问题