Iterating Through All Child Components in a Renderer (JSP)

You can aggregate the output of all child HstComponent instances in your JSP or Freemarker template, even when you do not know in advance which child components will be present. This approach is useful when the set of child components is dynamic or determined by configuration.

Explicit Child Components

When you know the exact child components to include, reference each one explicitly:

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

Aggregating All Child Components Dynamically

If you do not know the names or number of child components, iterate through all configured child components at runtime. The following example renders all child components in the order defined by the configuration.

JSP Example

<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>

Freemarker Example

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

This approach ensures that all child components configured for the current component are rendered, regardless of their names or count.

Share Feedback
Page: /frontend/standard-components/how-to-iterate-through-all-child-components-in-your-renderer-jsp
Section: Frontend
Category *