【发布时间】:2019-06-20 19:01:17
【问题描述】:
我正在尝试覆盖ProductImpl 中定义的以下属性的@AdminPresentation:
@Column(name = "DISPLAY_TEMPLATE")
@AdminPresentation(friendlyName = "ProductImpl_Product_Display_Template",
group = GroupName.Advanced)
protected String displayTemplate;
目前,它默认显示为文本字段,因为没有提供fieldType 属性。但我想显示一个带有预定义值的下拉选择菜单,例如Product 和Plan。到目前为止,这是我尝试过的:
我创建了一个实现BroadleafEnumerationType 的类DisplayTemplateType 并定义了PLAN 和PRODUCT 枚举。这是该类的代码:
public class DisplayTemplateType implements Serializable, BroadleafEnumerationType {
private static final long serialVersionUID = 7761108654549553693L;
private static final Map<String, DisplayTemplateType> TYPES = new LinkedHashMap<String, DisplayTemplateType>();
public static final DisplayTemplateType PLAN = new DisplayTemplateType("PLAN", "PLAN");
public static final DisplayTemplateType PRODUCT = new DisplayTemplateType("PRODUCT", "PRODUCT");
public static DisplayTemplateType getInstance(final String type) {
return TYPES.get(type);
}
private String type;
private String friendlyType;
public DisplayTemplateType() {
//do nothing
}
public DisplayTemplateType(final String type, final String friendlyType) {
this.friendlyType = friendlyType;
setType(type);
}
@Override
public String getType() {
return type;
}
@Override
public String getFriendlyType() {
return friendlyType;
}
private void setType(final String type) {
this.type = type;
if (!TYPES.containsKey(type)) {
TYPES.put(type, this);
} else {
throw new RuntimeException("Cannot add the type: (" + type + "). It already exists as a type via " + getInstance(type).getClass().getName());
}
}
// equals() and hashCode() implementation is removed for readability
}
然后在applicationContext-admin.xml 文件中,我添加了以下覆盖属性:
<mo:override id="blMetadataOverrides">
<mo:overrideItem ceilingEntity="org.broadleafcommerce.core.catalog.domain.Product">
<mo:field name="displayTemplate">
<mo:property name="explicitFieldType" value="BROADLEAF_ENUMERATION"/>
<mo:property name="broadleafEnumeration" value="com.community.core.domain.DisplayTemplateType"/>
</mo:field>
</mo:overrideItem>
</mo:override>
但这并没有改变任何东西。我在这里遗漏了什么吗?
【问题讨论】:
标签: java spring spring-mvc broadleaf-commerce