loading table of contents...

Content Application Developer Manual / Version 2310

Table Of Contents View Hooks

View Hooks provide a means to define extension points in JSP and FreeMarker templates. Project Extensions in Blueprint Developer Manual can make use of these extension points to add their own functionality at the respective locations in the resulting website without having to change the core templates.

In the past you either directly implemented the functions in your content beans and templates or you implemented a plugin by means of an Section 5.2, “Aspects” to achieve this. Both solutions are feasible however content beans and Aspects should only accomplish basic tasks based on the content defined by the editor and View Hooks are more loosely coupled and as such improve your project's code quality.

Required Configuration

View Hooks are not enabled by default. In order to use them in your templates you have to append the Spring bean viewHookEventView to the list of existing programmed views.

<customize:append id="customProgrammedViews" bean="programmedViews">
    <entry key=""

Instead of using a customizer you can also add the viewHookEventView to the existing map of programmedViews.

Example Implementation

Assuming there is a content bean CMArticle which represents an editorial article and a corresponding template called CMArticle.detail.jsp. The template defines an extension point with the id articleEnd.

<div class="detailView">

  <h1><c:out value="${self.title}"/></h1>
  <cm:include self="${self.text}" view="detailText"/>

  <cm:hook id="articleEnd" self="${self}"/>


A project extension now wants to add a list of user generated comments at the end of the article. Instead of changing the CMArticle.detail.jsp in the core modules directly, you only need to add an implementation of the to the Spring application context.

An implementation of this interface could look as follows:

public class CommentsViewHookEventListener implements ViewHookEventListener<CMArticle> {

  private CommentsService commentsService;

  public RenderNode onViewHook(ViewHookEvent<CMArticle> event) {
    if("articleEnd".equals(event.getId())) {
      CommentsResult commentsResult = commentsService.getCommentsResult(event.getBean());
      return new RenderNode(commentsResult);

    return null;

  public int getOrder() {
    return DEFAULT_ORDER;

The resulting com.coremedia.objectserver.view.RenderNode contains the object and the view name that will finally be passed to the Section, “View Lookup”. The view lookup is responsible for identifying and rendering the corresponding template or programmed view. Returning null tells the application to skip this listener.

Search Results

Table Of Contents

Your Internet Explorer is no longer supported.

Please use Mozilla Firefox, Google Chrome, or Microsoft Edge.