我有一个choicelist initializer,允许用户选择' image'或者'视频'。我需要那个:
umix:video
umix:image
和 umix:link
有可能吗?
以下是我所拥有的最小示例(问题在代码中作为注释):
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;
}
我知道我可以使用umix:image
和umix:link
等所有属性制作单个mixin,但我想知道是否有任何选项可以避免这种情况。
由于
答案 0 :(得分:0)
作为一种解决方法,您是否在cnd文件中尝试过类似的内容?这个想法是添加一个新的umix:videoimage嵌入了许多mixins。也许这会解决你的问题......
[umix:videoMix] mixin
- video (weakreference, picker[type='video']) i18n mandatory < jnt:file
[umix:imageMix] mixin
- image (weakreference, picker[type='image']) i18n mandatory < jnt:file
[umix:video] > umix:templateMixin,umix:videoMix mixin
extends = unt:homeHeader
[umix:image] > umix:templateMixin,umix:imageMix mixin
extends = unt:homeHeader
[umix:videoimage] > umix:templateMixin,umix:videoMix,umix:imageMix mixin
extends = unt:homeHeader