4. DynamicTilesView

Processing Order

If a request is made for '/info/index.html', Spring will pass 'info/index' into the view. The first thing will be to look for 'info/index' as a Tiles definition. Then a template definition of '.info.mainTemplate', which if found will dynamically have a body set on this definition. If the previous aren't found, it is assumed a root definition exists. This would be '.mainTemplate'. If none of these exist, a TilesException will be thrown.

  1. Check if a Tiles definition based on the URL matches.
  2. Checks if a definition derived from the URL and default template name exists and then dynamically insert the body based on the URL.
  3. Check if there is a root template definition and then dynamically insert the body based on the URL.
  4. If no match is found from any process above a TilesException is thrown.

The following are the default values for determining a Tiles definition for a request. If these aren't acceptable, they can be changed using TilesUrlBasedViewResolver which is a subclass of UrlBasedViewResolver. Or for AJAX support TilesAjaxUrlBasedViewResolver, which is a subclass of AjaxUrlBasedViewResolver, can be used.

Table 1. DynamicTilesView Defaults

PropertyDefault Value
tilesDefinitionNamemainTemplate
tilesBodyAttributeNamecontent
tilesDefinitionDelimiter.

                    
<bean id="dynamicTilesViewResolver"
      class="org.springbyexample.web.servlet.view.tiles2.TilesUrlBasedViewResolver">
    <property name="viewClass" value="org.springbyexample.web.servlet.view.tiles2.DynamicTilesView" />
    <property name="prefix" value="/WEB-INF/jsp/"/>
    <property name="suffix" value=".jsp"/>
    <property name="tilesDefinitionName" value="root" />
    <property name="tilesBodyAttributeName" value="content" />
    <property name="tilesDefinitionDelimiter" value="-" />
</bean>