This article covers a Bloomreach Experience Manager version 13. There's an updated version available that covers our most recent release.

Selection Plugin Delivery Tier Configuration and Implementation

Content Bean

You can use the Beanwriter tool in the setup application to update the content bean for the document type you added the selection field to.

At repository level a selection field is simply a String (or Boolean) property, so the corresponding get method in the content bean is no different from that of a regular String property:

@HippoEssentialsGenerated(internalName = "myproject:city")
public String getCity() {
    return getProperty("myproject:city");
}

Make Value Lists Available to the Site

When a CMS user selects a value from a selection field in a document's editing template, the key for that value is stored in the repository. In order to render the label value associated with that key, you need access to the value list from the delivery tier.

The setup application provides a UI to make value lists available to the site application, by means of the ValueListManager Spring bean.

valueListManager.xml

The generated Spring bean configuration can be found in your project's site module in  site/components/src/main/resources/META-INF/hst-assembly/overrides/valueListManager.xml:

<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-3.0.xsd">  
  <bean id="org.onehippo.forge.selection.hst.manager.ValueListManager" 
        class="org.onehippo.forge.selection.hst.manager.DefaultValueListManager"> 
    <constructor-arg> 
      <map> 
        <!--<entry key="name" value="/absolute/repository/path"/>-->  
        <entry key="cities" value="/content/documents/administration/value-lists/cities"/>
      </map> 
    </constructor-arg> 
  </bean> 
</beans>

Access value lists

You can access the ValueListManager bean from within any page component class. The example below extends the standard Content Component and overrides its doBeforeRender method to retrieve the cities value list and put it in a request attribute:

public class NewsComponent extends EssentialsContentComponent {

    @Override
    public void doBeforeRender(HstRequest request, HstResponse response) {
        super.doBeforeRender(request, response);

        final ValueList citiesValueList = 
            SelectionUtil.getValueListByIdentifier("cities", RequestContextProvider.get());
        if (citiesValueList != null) {
            request.setAttribute("citiesMap", SelectionUtil.valueListAsMap(citiesValueList));
        }
    }
}

Template

In your template you can then use the value list to lookup the value label for the key stored in a document:

${citiesMap[document.city]}
Did you find this page helpful?
How could this documentation serve you better?
On this page
    Did you find this page helpful?
    How could this documentation serve you better?