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

How to iterate through all child components in your renderer (jsp)

Sometimes, you just want to aggregate the output of all child HstComponents in your JSP/freemarker template, and you do not know on beforehand which child components to expect. Thus, for example, the normal way does not apply:

Explicit child components:

<body>
  <div id="custom-doc" class="yui-t6">
    <hst:include ref="header"/>
    <hst:include ref="body"/>
    <hst:include ref="footer"/>
  </div>
</body>

When you do not know that you have a child component header, body and footer, you can also use the following for aggregating all child components (in the order of the configuration they are rendered)

Aggregate all child components in a JSP:

<body>
  <div id="custom-doc" class="yui-t6">
    <hst:defineObjects/>
    <c:forEach var="childContentName" items="${hstResponse.childContentNames}">
       <hst:include ref="${childContentName}"/>
    </c:forEach>
  </div>
</body>

And its freemarker equivalent:

<body>
  <div id="custom-doc" class="yui-t6">
    <@hst.defineObjects/>
    <#list hstResponseChildContentNames as childContentName>
      <@hst.include ref="${childContentName}"/>
    </#list>
  </div>
</body>
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?

    We rely on cookies

    to optimize our communication and to enhance your customer experience. By clicking on the Accept and Close button, you agree to the collection of cookies. You can also adjust your preferences by clicking on Manage Preferences. For more information please see our Privacy policy.

    Manage cookies
    Accept & close

    Cookies preferences

    Accept & close
    Back