From fb600857df9a1fd4f44158c2537e3c2bee4322b5 Mon Sep 17 00:00:00 2001 From: Sebastien Deleuze Date: Mon, 17 Mar 2014 11:02:36 +0100 Subject: [PATCH] Document locale convention in Tiles def file names In Tiles v3 integration, underscores in filenames are intended to identify the definition locale. This behavior is now documented in order to avoid unexpected results with filenames like tiles_definitions.xml. This commit also updates Tiles v2 references to Tiles v3 in the Spring reference documentation. Issue: SPR-11491 --- build.gradle | 1 + .../servlet/view/tiles3/TilesConfigurer.java | 16 +++++- src/asciidoc/index.adoc | 49 +++++++++++++------ 3 files changed, 50 insertions(+), 16 deletions(-) diff --git a/build.gradle b/build.gradle index f126d8a30be..a29d52ed1d4 100644 --- a/build.gradle +++ b/build.gradle @@ -97,6 +97,7 @@ configure(allprojects) { project -> "http://commons.apache.org/proper/commons-codec/apidocs/", "http://commons.apache.org/proper/commons-dbcp/apidocs/", "http://portals.apache.org/pluto/portlet-2.0-apidocs/", + "http://tiles.apache.org/tiles-request/apidocs/", "http://tiles.apache.org/framework/apidocs/", "http://aopalliance.sourceforge.net/doc/", "http://www.eclipse.org/aspectj/doc/released/aspectj5rt-api/", diff --git a/spring-webmvc-tiles3/src/main/java/org/springframework/web/servlet/view/tiles3/TilesConfigurer.java b/spring-webmvc-tiles3/src/main/java/org/springframework/web/servlet/view/tiles3/TilesConfigurer.java index 794b1534b78..01f37c83bfa 100644 --- a/spring-webmvc-tiles3/src/main/java/org/springframework/web/servlet/view/tiles3/TilesConfigurer.java +++ b/spring-webmvc-tiles3/src/main/java/org/springframework/web/servlet/view/tiles3/TilesConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -100,6 +100,20 @@ import org.springframework.web.context.ServletContextAware; * The values in the list are the actual Tiles XML files containing the definitions. * If the list is not specified, the default is {@code "/WEB-INF/tiles.xml"}. * + *

Note that in Tiles 3 an underscore in the name of a file containing Tiles + * definitions is used to indicate locale information, for example: + * + *

+ * <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
+ *   <property name="definitions">
+ *     <list>
+ *       <value>/WEB-INF/defs/tiles.xml</value>
+ *       <value>/WEB-INF/defs/tiles_fr_FR.xml</value>
+ *     </list>
+ *   </property>
+ * </bean>
+ * 
+ * * @author mick semb wever * @author Rossen Stoyanchev * @since 3.2 diff --git a/src/asciidoc/index.adoc b/src/asciidoc/index.adoc index 0dc55a588b2..e49c4a95666 100644 --- a/src/asciidoc/index.adoc +++ b/src/asciidoc/index.adoc @@ -33380,17 +33380,11 @@ This section focuses on Spring's support for Tiles v3 in the ==== - [[view-tiles-dependencies]] ==== Dependencies -To be able to use Tiles you have to have a couple of additional dependencies included in -your project. The following is the list of dependencies you need. - -* `Tiles version 2.1.2 or higher` -* `Commons BeanUtils` -* `Commons Digester` -* `Commons Logging` - +To be able to use Tiles, you have to add a dependency on Tiles version 3.0.1 or higher +and http://tiles.apache.org/framework/dependency-management.html[its transitive dependencies] +to your project. [[view-tiles-integrate]] @@ -33403,7 +33397,7 @@ look at the following piece of example ApplicationContext configuration: [source,xml,indent=0] [subs="verbatim,quotes"] ---- - + /WEB-INF/defs/general.xml @@ -33424,6 +33418,31 @@ Spring web application. To be able to use the views you have to have a `ViewReso just as with any other view technology used with Spring. Below you can find two possibilities, the `UrlBasedViewResolver` and the `ResourceBundleViewResolver`. +You can specify locale specific Tiles definitions by adding an underscore and then +the locale. For example: + +[source,xml,indent=0] +[subs="verbatim,quotes"] +---- + + + + /WEB-INF/defs/tiles.xml + /WEB-INF/defs/tiles_fr_FR.xml + + + +---- + +With this configuration, `tiles_fr_FR.xml` will be used for requests with the `fr_FR` locale, +and `tiles.xml` will be used by default. + +[NOTE] +==== +Since underscores are used to indicate locales, it is recommended to avoid using +them otherwise in the file names for Tiles definitions. +==== + [[view-tiles-url]] ===== UrlBasedViewResolver @@ -33435,7 +33454,7 @@ resolve. [subs="verbatim,quotes"] ---- - + ---- @@ -33458,10 +33477,10 @@ viewnames and viewclasses the resolver can use: [subs="verbatim,quotes"] ---- ... - welcomeView.(class)=org.springframework.web.servlet.view.tiles2.TilesView + welcomeView.(class)=org.springframework.web.servlet.view.tiles3.TilesView welcomeView.url=welcome (this is the name of a Tiles definition) - vetsView.(class)=org.springframework.web.servlet.view.tiles2.TilesView + vetsView.(class)=org.springframework.web.servlet.view.tiles3.TilesView vetsView.url=vetsView (again, this is the name of a Tiles definition) findOwnersForm.(class)=org.springframework.web.servlet.view.JstlView @@ -33500,7 +33519,7 @@ per preparer name (as used in your Tiles definitions). [source,xml,indent=0] [subs="verbatim,quotes"] ---- - + /WEB-INF/defs/general.xml @@ -33513,7 +33532,7 @@ per preparer name (as used in your Tiles definitions). + value="org.springframework.web.servlet.view.tiles3.SpringBeanPreparerFactory"/> ----