tiles-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brett Ryan <brett.r...@gmail.com>
Subject Re: How does one use localised tiles definitions with Spring?
Date Tue, 23 Aug 2016 13:54:31 GMT
Oh god, I'm a wank!

I had my tiles_fr.xml spelt tiiles_fr.xml.

I knew this worked in prior projects.

So sorry guys, completely forget this one.

> On 23 Aug 2016, at 22:44, Brett Ryan <brett.ryan@gmail.com> wrote:
> 
> 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.
> 
> 
> 


Mime
View raw message