tiles-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brett Ryan <brett.r...@gmail.com>
Subject How does one use localised tiles definitions with Spring?
Date Tue, 23 Aug 2016 12:44:42 GMT
Hey all, trying to determine how to use tiles definitions within a spring mvc application using
a spring cookie locale resolver.

My spring resource bundles are being changed properly as by my <spring:message/> tags,
and ${pageContext.response.locale} reports the correct locale, however my tiles definitions
aren't being picked up. I wish to have a different layout for some locales.

My TilesConfigurer is as follows:

    public TilesConfigurer tilesConfigurer() {
        TilesConfigurer res = new TilesConfigurer();
        res.setTilesInitializer(new SpringCompleteAutoloadTilesInitializer());
        return res;
SpringCompleteAutoloadTilesInitializer is a custom initialiser that looks as follows:

public class SpringCompleteAutoloadTilesContainerFactory extends CompleteAutoloadTilesContainerFactory

    protected PreparerFactory createPreparerFactory(ApplicationContext context) {
        return new SpringBeanPreparerFactory();

    protected LocaleResolver createLocaleResolver(ApplicationContext applicationContext) {
        return new SpringLocaleResolver();


I verified that the locale is working and gets returned correctly on each request by creating
a wrapper class, so the locale is getting returned.

Now for my definitions I have


  <definition name="home" extends="default.layout">
    <put-list-attribute name="body" inherit="true" cascade="true">
      <add-attribute value="/WEB-INF/views/home.jsp" />

and tiles_fr.xml

  <definition name="home" extends="default.layout">
    <put-list-attribute name="body" inherit="true" cascade="true">
      <add-attribute value="/WEB-INF/views/home_fr.jsp" />

Everything runs fine, yet for the "home" view, the home_fr.jsp is not being rendered, home.jsp
gets rendered.

View raw message