spring-mvctomcatapache-tilestiles-3

Disable multilingual option in Apache tiles 3


I am getting following warning with Apche tiles 3 and Spring MVC 4 I does not added any extra configurations for multilingual support but it supporting by default. Can any one help me to disable this option to remove this warning in my site.

    org.apache.tiles.request.locale.PostfixedApplicationResource.
<init> No supported matching language for locale "sw". 
Using file:/opt/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/tiles/app-core_sw.xml as a non-localized resource path. see TILES-571

Solution

  • You can disable this option by writing your own DefinitionFactory implementation and registering the same in TilesConfigurer.

    public class CustomLocaleDefinitionsFactory extends LocaleDefinitionsFactory {
    
        /** {@inheritDoc} */
        @Override
        public Definition getDefinition(String name, Request tilesContext) {
        Definition retValue;
        Locale locale = null;
    
        retValue = definitionDao.getDefinition(name, locale);
        if (retValue != null) {
          retValue = new Definition(retValue);
          String parentDefinitionName = retValue.getExtends();
          while (parentDefinitionName != null) {
            Definition parent = definitionDao.getDefinition(parentDefinitionName, locale);
            if (parent == null) {
              throw new NoSuchDefinitionException("Cannot find definition '" + parentDefinitionName
                  + "' ancestor of '" + retValue.getName() + "'");
            }
            retValue.inherit(parent);
            parentDefinitionName = parent.getExtends();
          }
        }
    
        return retValue;
        }
    }
    

    And then in register the above definition factor class, in TilesConfigurer in case using spring like this.

    TilesConfigurer configurer = new TilesConfigurer();
    configurer.setDefinitions(new String[] { "/WEB-INF/layouts/tiles.xml",
        "/WEB-INF/views/**/tiles.xml" });
    configurer.setCheckRefresh(true);
    configurer.setDefinitionsFactoryClass(CustomLocaleDefinitionsFactory.class);
    return configurer;