Custom Label Provider not working in Backoffice for component=”base”

Total
21
Shares

SAP Commerce 1811

I have created one custom Label Provider for one of my custom item type and applied it for component="base" but its not working in Backoffice.

CustomLabelProvider- Created inside backoffice/src folder

public class CustomLabelProvider implements LabelProvider<CustomABCModel>
{  
    @Override
    public String getLabel(final CustomABCModel model)
    {
        // some custom logic
        return label;
    }

    @Override
    public String getDescription(final CustomABCModel model)
    {
       return getLabel(model);
    }

    @Override
    public String getIconPath(final CustomABCModel model)
    {
       return null;
    }
}

mybackoffice-backoffice-spring.xml

<bean id="customLabelProvider" class="com.hybris.backoffice.labels.impl.CustomLabelProvider"/>

mybackoffice-backoffice-config.xml

<context type="CustomABC" component="base" merge-by="type">
    <y:base>
        <y:labels>
            <y:labels beanId="customLabelProvider"/>
        </y:labels>
    </y:base>
</context>

I have done all the steps but somehow its not working. Label not showing in Backoffice.

Any help on whats going wrong here?


Solution

Labels tag cannot have an under tag labels, this the related xsd structure for Labels tag :

<xs:complexType name="labels">
        <xs:all>
            <xs:element name="label" type="xs:string" minOccurs="0"/>
            <xs:element name="shortLabel" type="xs:string" minOccurs="0"/>
            <xs:element name="description" type="xs:string" minOccurs="0"/>
            <xs:element name="iconPath" type="xs:string" minOccurs="0"/>
        </xs:all>
        <xs:attribute name="beanId" type="xs:string"/>
</xs:complexType>

So you probably wanted to do this instead :

<context type="CustomABC" component="base" merge-by="type">
    <y:base>
        <y:labels beanId="customLabelProvider"/>
    </y:base>
</context>
Leave a Reply

Your email address will not be published. Required fields are marked *