I have a choicelist initializer that allows a user to choose 'image' or 'video'. I need that :
- if the 'video' type is selected, apply mixin
umix:video - if the 'image' type is selected, apply mixins
umix:imageandumix:link
Is it possible ?
Here is a minimal example of what I have (question is in the code as a comment) :
definitions.cnd :
[unt:homeHeader] > jnt:content
- type (string, choicelist[homeHeaderTypeListInitializer,resourceBundle]) = 'image' mandatory autocreated nofulltext
[umix:video] > jmix:templateMixin mixin
extends = unt:homeHeader
- video (weakreference, picker[type='video']) i18n mandatory < jnt:file
[umix:image] > jmix:templateMixin mixin
extends = unt:homeHeader
- image (weakreference, picker[type='image']) i18n mandatory < jnt:file
[umix:link] > jmix:templateMixin mixin
extends = unt:homeHeader
- title (string) i18n < '^.{1,255}$'
- url (string) = 'https://' i18n mandatory indexed=no
homeHeaderTypeListInitializer.java :
public List<ChoiceListValue> getChoiceListValues(ExtendedPropertyDefinition epd, String param, List<ChoiceListValue> values, Locale locale, Map<String, Object> context) {
List<ChoiceListValue> myChoiceList = new ArrayList<>();
if (context == null) {
return myChoiceList;
}
HashMap<String, Object> myPropertiesMap;
myPropertiesMap = new HashMap<>();
myPropertiesMap.put("addMixin", "umix:image");
// HOW CAN I ADD THE SECOND MIXIN umix:link HERE ?
myChoiceList.add(new ChoiceListValue("image", myPropertiesMap, new ValueImpl("image", PropertyType.STRING, false)));
myPropertiesMap = new HashMap<>();
myPropertiesMap.put("addMixin", "umix:video");
myChoiceList.add(new ChoiceListValue("video", myPropertiesMap, new ValueImpl("video", PropertyType.STRING, false)));
return myChoiceList;
}
I know that I can make a single mixin with all the properties from umix:image and umix:link, etc. but I want to know if there is any option to avoid that.
Thanks
As a workaround, did you try something like this in the cnd file? The idea would be to add a new umix:videoimage that embed many mixins. Maybe it would solve your issue...