Template Composer Component Parameters - BloomReach Experience - Open Source CMS

Template Composer Component Parameters

The HST components behind catalog items can define parameters that influence their behavior. These parameters can be edited in the template composer.

Editable Component Parameters

An HST component can define a separate interface for all its parameters that should be exposed in the template composer. Each parameter must be defined by a getter method in the interface that is annotated with  @org.hippoecm.hst.core.parameters.Parameter. The HstComponent class itself must be annotated with the class @org.hippoecm.hst.core.parameters.ParametersInfo that indicates which interface to use for the parameters of that HST component.

When the user selects the component in the Template Composer, the parameter annotations in the interface of the component are automatically scanned and the corresponding UI is rendered in the component's properties window.


Say we have a component that displays the latest items (like comments/news items etc.). We want to have a 'limit' parameter that determines the maximum number of items to display. End users should be able to modify this 'limit' parameter via the Template Composer.

First you need to create the interface for the parameters of the LatestItems component:

public interface LatestItemsParamsInfo {

    String PARAM_LIMIT = "limit";

    @Parameter(name = PARAM_LIMIT, required = true,

               displayName = "Limit", defaultValue = "5")

    int getLimit();


Note that the getter is annotated with an  @Parameter annotation. Other annotations can be added to specify a specific widget to render in the CMS UI for editing the parameter.

Second, the HST component class must indicate the parameters interface to use in a @ParametersInfo annotation:

@ParametersInfo(type = LatestItemsParamsInfo.class)

public class LatestItems extends BaseHstComponent {



The method LatestItems#doBeforeRender can now use the interface to get the values for the parameters:

LatestItemsParamsInfo paramsInfo = getComponentParametersInfo(request);

String limitParam = paramsInfo.getLimit();

The HST will automatically create a proxy class for the annotated parameters info interface. The methods work similar to the HSTComponent#getComponentParameter method.

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?