Reloading Tiles2 Config in Spring 3.x

When you are using Tiles for layout composition with Spring you configure it as a view resolver by adding something like this to the applicationContext.xml

    <!-- Configure the Tiles templates -->
    <bean id="tilesConfigurer"
        class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
        <property name="definitions">
            <list>
                <value>/WEB-INF/tiles.xml</value>
            </list>
        </property>
        <property name="preparerFactoryClass"
            value="org.springframework.web.servlet.view.tiles2.SpringBeanPreparerFactory" />
    </bean>
    <!-- Resolve views using Tiles -->
    <bean id="tilesViewResolver"
        class="org.springframework.web.servlet.view.UrlBasedViewResolver">
        <property name="viewClass"
            value="org.springframework.web.servlet.view.tiles2.TilesView" />
    </bean>

This will read the tiles.xml on startup. If you want it to refresh when the file changes you either need to add the Tiles filter, or more elegantly just add this context-param to the web.xml

<context-param>   <param-name>org.apache.tiles.definition.dao.LocaleUrlDefinitionDAO.CHECK_REFRESH</param-name>  <param-value>true</param-value> </context-param> 

Even better for testing environments, you can also put the declaration in your context.xml file, so you can switch it on and off on a per-deployment basis

    <Parameter name="org.apache.tiles.definition.dao.LocaleUrlDefinitionDAO.CHECK_REFRESH"
        value="true" override="false" />

 

This entry was posted in Spring. Bookmark the permalink.

One Response to Reloading Tiles2 Config in Spring 3.x

  1. Pingback: Javascript utf-8 substr and length function - Acampora

Leave a Reply