问题描述
SAP Commerce 1811
我们有一个这样的模型..
HolidayCalendar 具有整数类型的属性年和假日日历条目的集合。
HolidayCalendarEntry 具有属性日期
在后台 -> 创建/编辑器向导中,我想在 HolidayCalendar:Entries 属性上应用 referenceSearchCondition 过滤器,这样每当我选择假日日历中的现有条目时,我只能得到那些属于相关年份的条目.
例如我创建了新的 2021 年假日日历,然后我只能看到那些日期为 2021 年的条目。
到目前为止,我尝试使用 Dynamic Form 进行了一些操作,但它不起作用
<context type="HolidayCalendar" component="editorAreaDynamicForms" merge-by="module">
<df:dynamicForms xmlns:df="http://www.hybris.com/cockpitng/component/dynamicForms">
<df:attribute id="dynamicFormsEntryFiltering1" paramName="referenceSearchCondition_date_greaterOrEquals" disabledIf="date==null" computedValue="T(com.hybris.util.DateUtils).getFirstDay(parentObject.year)" qualifier="entries" triggeredOn="date"/>
</df:dynamicForms>
</context>
<context type="HolidayCalendar" component="editorAreaDynamicForms" merge-by="module">
<df:dynamicForms xmlns:df="http://www.hybris.com/cockpitng/component/dynamicForms">
<df:attribute id="dynamicFormsEntryFiltering2" paramName="referenceSearchCondition_date_lessOrEquals" disabledIf="date==null" computedValue="T(com.hybris.util.DateUtils).getLastDay(parentObject.year)" qualifier="entries" triggeredOn="date"/>
</df:dynamicForms>
</context>
在这里,我试图设置假日日历年的 FirstDay 和 LastDay 范围,并且匹配条目日期属于它。但它不起作用。
对于如何实现这一目标还有其他建议吗?
解决方法
您可以为“条目”属性创建自定义编辑器,
public class EntriesEditor<T> extends DefaultMultiReferenceEditor<T>
覆盖该方法并在该方法中添加过滤条件
- updateReferencesListBoxModel
在 config.xml 中引用这个自定义编辑器,