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:

    @Bean
    public TilesConfigurer tilesConfigurer() {
        TilesConfigurer res = new TilesConfigurer();
        res.setTilesInitializer(new SpringCompleteAutoloadTilesInitializer());
        res.setDefinitions("/WEB-INF/**/tiles*.xml");
        return res;
    }
 
SpringCompleteAutoloadTilesInitializer is a custom initialiser that looks as 
follows:

public class SpringCompleteAutoloadTilesContainerFactory extends 
CompleteAutoloadTilesContainerFactory {

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

    @Override
    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

tiles.xml:

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

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" />
    </put-list-attribute>
  </definition>

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



Reply via email to