Adding valuelists via ValueListProviderService

Hi Community,

Since the “valueListProvider” is deprecated in @DropdownList and in order to make use of valueListProviderKey I am trying to inject a ValueList into customValueListProviders via ValueListProviderService as explained in the doc

However, when the execution reaches the constructor of ValueListProviderServiceImpl, the map customProviders remains empty.

Please see below the XML snippet and ValueListProvider code that I am using. This file is located at META-INF/hst-assembly/overrides/addon/org/hippoecm/hst/platform/valuelistproviders.xml in the site project of a Bloomreach 14.7.4 archetype project.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-4.1.xsd">

    <bean id="customValueListProviders" class="org.springframework.beans.factory.config.MapFactoryBean">
        <property name="targetMapClass">
            <value>java.util.HashMap</value>
        </property>
        <property name="sourceMap">
            <map>
                <entry key="color-themes" value="org.example.beans.TestProvider" />
            </map>
        </property>
    </bean>
</beans>

public class TestProvider implements ValueListProvider {
    List<String> values = Arrays.asList("test1", "test2", "test3");
    @Override
    public List<String> getValues() {
        return values;
    }

    @Override
    public String getDisplayValue(final String value) {
        return getDisplayValue(value, null);
    }

    @Override
    public String getDisplayValue(final String value, final Locale locale) {
        return value;
    }
}

Thanks in advance.

Kind Regards
Mehul Parmar

1 Like

Hi,

I have run into this issue myself, but unfortunately I do not have a solution for you. For now please use the deprecated method, though it is expected to be removed in some future release. We are investigating this issue.

Hi Jasper,

Thanks for your reply. Following your advice we’ll keep using the deprecated method. Could you please update the documentation in case anyone else tries to follow the steps mentioned?

Kind Regards
Mehul Parmar

Hi, is there still no solution for this problem? It’s frustrating if you follow the steps and it does not work :face_with_raised_eyebrow:

Hi Kitty,

I understand such frustration, we needed to find some priority to check it… This case turned out to be caused by moving large parts of the HST into the CMS webapp. So the ‘customValueListProviders’ should be in the platform Spring context, meaning in the CMS webapp where the file path must match the pattern META-INF/hst-assembly/overrides/addon/org/hippoecm/hst/platform/*.xml.

We’ve updated the documentation page as well.

Hope that works out,
Thanks,
Jeroen