loading table of contents...

Content Application Developer Manual / Version 2310

Table Of Contents Using Multiple View Repositories

In a smaller project it might be sufficient to use a single view repository only.

When hosting several sites with different template sets in a single CAE, multiple view repositories may be used. The CAE provides a mechanism for choosing a set of view repositories dynamically per request.

This mechanism is separated into two services that are implementations of ViewRepositoryNameProvider and ViewRepositoryProvider respectively.


The ViewRepositoryNameProvider is responsible for providing the names of the view repositories to be used for resolving templates for the current request. For instance, if a page is requested that is located in a "sports" subsite within a larger site, a list [sports,site] might be returned where "site" refers to a common template sets that is used when the more special set "sports" does not provide a matching template. If another request is sent for a "politics" page, then a list [politics,site] might be returned so that the output is rendered differently due to the use of different templates.

A default implementation StaticViewRepositoryNameProvider returns a list of predefined view repository names. Another default implementation CompoundViewRepositoryNameProvider returns the view repository names from several view repository name providers. Applications that require more flexibility must implement the interface ViewRepositoryNameProvider to return a project specific list of view repository names.


The ViewRepositoryProvider is responsible for providing a ViewRepository instance for a given name. A default implementation TemplateViewRepositoryProvider is included. It inserts the repository name into a configured base path format pattern, for example, a name "sports" with a format /WEB-INF/templates/%s provides a ViewRepository instance with a base path /WEB-INF/templates/sports.

The following example configuration registers a custom ViewRepositoryNameProvider and a TemplateViewRepositoryProvider to locate view repositories using the pattern /WEB-INF/templates/sites/<viewRepositoryName>

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""

    Instance of the project specific viewRepositoryNameProvider
  <bean id="customViewRepositoryNameProvider"

   Register the view repository name provider
  <customize:append id="addCustomViewRepositoryNameProvider"
      <ref bean="customViewRepositoryNameProvider"/>

   Create an instance of TemplateViewRepositoryProvider
  <bean id="customViewRepositoryProvider"
    <property name="templatesLocationFormat"
    <!-- configure predefined beans -->
    <property name="viewDecorators" ref="viewDecorators"/>
    <property name="viewEngines" ref="viewEngines"/>
    <property name="loader" ref="templatesResourceLoader"/>
    <property name="programmedViews" ref="programmedViews"/>

   Register the view repository provider
  <customize:append id="addCustomViewRepositoryProvider"
      <ref bean="customViewRepositoryProvider"/>

Search Results

Table Of Contents

Your Internet Explorer is no longer supported.

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