Not sure if this will work in jmix 2.0
. But as I can see. PropertyFilter
use PropertyFilterComponentGenerationStrategy
to generate its components.
So u can override
its method createEntityField(ComponentGenerationContext context)
(or createEntityField(ComponentGenerationContext context, MetaPropertyPath mpp)
in jmix 1.5
) to create field. In our application we used it like that (jmix 1.5
):
@Primary
@org.springframework.stereotype.Component
class OurPropertyFilterComponentGenerationStrategy(...) : PropertyFilterComponentGenerationStrategy(..) {
override fun createEntityField(context: ComponentGenerationContext, mpp: MetaPropertyPath): Component {
if (mpp.range.isClass) {
val metaClass = mpp.range.asClass()
if (metaClass == metadata.getClass(FirstEntity::class.java)) {
return createSuggestionPickerFieldForFirstEntity(mpp)
}
if (metaClass == metadata.getClass(SecondEntity::class.java)) {
return createSuggestionPickerFieldForSecondEntity()
}
}
return super.createEntityField(context, mpp)
}
}