mvc:tiles-configurer supports preparer-factory and definitions-factory
Issue: SPR-13363
This commit is contained in:
parent
8cd283729b
commit
6aa9e0caf9
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
|
@ -29,9 +29,10 @@ import org.springframework.util.xml.DomUtils;
|
|||
|
||||
/**
|
||||
* Parse the <mvc:tiles-configurer> MVC namespace element and register
|
||||
* TilesConfigurer bean
|
||||
* a corresponding TilesConfigurer bean.
|
||||
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Juergen Hoeller
|
||||
* @since 4.1
|
||||
*/
|
||||
public class TilesConfigurerBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
@ -49,11 +50,6 @@ public class TilesConfigurerBeanDefinitionParser extends AbstractSingleBeanDefin
|
|||
return BEAN_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldGenerateId() {
|
||||
return super.shouldGenerateId();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
List<Element> childElements = DomUtils.getChildElementsByTagName(element, "definitions");
|
||||
|
@ -70,6 +66,12 @@ public class TilesConfigurerBeanDefinitionParser extends AbstractSingleBeanDefin
|
|||
if (element.hasAttribute("validate-definitions")) {
|
||||
builder.addPropertyValue("validateDefinitions", element.getAttribute("validate-definitions"));
|
||||
}
|
||||
if (element.hasAttribute("definitions-factory")) {
|
||||
builder.addPropertyValue("definitionsFactoryClass", element.getAttribute("definitions-factory"));
|
||||
}
|
||||
if (element.hasAttribute("preparer-factory")) {
|
||||
builder.addPropertyValue("preparerFactoryClass", element.getAttribute("preparer-factory"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1128,6 +1128,22 @@
|
|||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="definitions-factory" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
The Tiles DefinitionsFactory class to use. Default is Tiles' default.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="preparer-factory" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
The Tiles PreparerFactory class to use. Default is Tiles' default.
|
||||
Consider "org.springframework.web.servlet.view.tiles3.SimpleSpringPreparerFactory" or
|
||||
"org.springframework.web.servlet.view.tiles3.SpringBeanPreparerFactory" (see javadoc).
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
|
|||
import com.fasterxml.jackson.databind.MapperFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
|
||||
import org.apache.tiles.definition.UnresolvingLocaleDefinitionsFactory;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.junit.Before;
|
||||
|
@ -136,6 +137,7 @@ import org.springframework.web.servlet.view.groovy.GroovyMarkupConfigurer;
|
|||
import org.springframework.web.servlet.view.groovy.GroovyMarkupViewResolver;
|
||||
import org.springframework.web.servlet.view.script.ScriptTemplateConfigurer;
|
||||
import org.springframework.web.servlet.view.script.ScriptTemplateViewResolver;
|
||||
import org.springframework.web.servlet.view.tiles3.SpringBeanPreparerFactory;
|
||||
import org.springframework.web.servlet.view.tiles3.TilesConfigurer;
|
||||
import org.springframework.web.servlet.view.tiles3.TilesViewResolver;
|
||||
import org.springframework.web.servlet.view.velocity.VelocityConfigurer;
|
||||
|
@ -779,6 +781,8 @@ public class MvcNamespaceTests {
|
|||
accessor = new DirectFieldAccessor(tilesConfigurer);
|
||||
assertArrayEquals(definitions, (String[]) accessor.getPropertyValue("definitions"));
|
||||
assertTrue((boolean) accessor.getPropertyValue("checkRefresh"));
|
||||
assertEquals(UnresolvingLocaleDefinitionsFactory.class, accessor.getPropertyValue("definitionsFactoryClass"));
|
||||
assertEquals(SpringBeanPreparerFactory.class, accessor.getPropertyValue("preparerFactoryClass"));
|
||||
|
||||
FreeMarkerConfigurer freeMarkerConfigurer = appContext.getBean(FreeMarkerConfigurer.class);
|
||||
assertNotNull(freeMarkerConfigurer);
|
||||
|
|
|
@ -2,42 +2,43 @@
|
|||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<mvc:view-resolvers>
|
||||
<mvc:bean-name />
|
||||
<mvc:jsp view-class="org.springframework.web.servlet.view.InternalResourceView" />
|
||||
<mvc:tiles />
|
||||
<mvc:freemarker prefix="freemarker-" suffix=".freemarker" view-names="my*,*Report" />
|
||||
<mvc:velocity cache-views="false" />
|
||||
<mvc:groovy />
|
||||
<mvc:script-template />
|
||||
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" />
|
||||
<ref bean="customResolver" />
|
||||
<mvc:bean-name/>
|
||||
<mvc:jsp view-class="org.springframework.web.servlet.view.InternalResourceView"/>
|
||||
<mvc:tiles/>
|
||||
<mvc:freemarker prefix="freemarker-" suffix=".freemarker" view-names="my*,*Report"/>
|
||||
<mvc:velocity cache-views="false"/>
|
||||
<mvc:groovy/>
|
||||
<mvc:script-template/>
|
||||
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"/>
|
||||
<ref bean="customResolver"/>
|
||||
</mvc:view-resolvers>
|
||||
|
||||
<bean id="customResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" />
|
||||
<bean id="customResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"/>
|
||||
|
||||
<mvc:tiles-configurer check-refresh="true" validate-definitions="true">
|
||||
<mvc:definitions location="/org/springframework/web/servlet/resource/tiles/tiles1.xml" />
|
||||
<mvc:definitions location="/org/springframework/web/servlet/resource/tiles/tiles2.xml" />
|
||||
<mvc:tiles-configurer check-refresh="true" validate-definitions="true"
|
||||
definitions-factory="org.apache.tiles.definition.UnresolvingLocaleDefinitionsFactory"
|
||||
preparer-factory="org.springframework.web.servlet.view.tiles3.SpringBeanPreparerFactory">
|
||||
<mvc:definitions location="/org/springframework/web/servlet/resource/tiles/tiles1.xml"/>
|
||||
<mvc:definitions location="/org/springframework/web/servlet/resource/tiles/tiles2.xml"/>
|
||||
</mvc:tiles-configurer>
|
||||
|
||||
<mvc:freemarker-configurer>
|
||||
<mvc:template-loader-path location="/" />
|
||||
<mvc:template-loader-path location="/test" />
|
||||
<mvc:template-loader-path location="/"/>
|
||||
<mvc:template-loader-path location="/test"/>
|
||||
</mvc:freemarker-configurer>
|
||||
|
||||
<mvc:velocity-configurer resource-loader-path="/test" />
|
||||
<mvc:velocity-configurer resource-loader-path="/test"/>
|
||||
|
||||
<mvc:groovy-configurer resource-loader-path="/test" cache-templates="false" auto-indent="true" />
|
||||
<mvc:groovy-configurer resource-loader-path="/test" cache-templates="false" auto-indent="true"/>
|
||||
|
||||
<mvc:script-template-configurer engine-name="nashorn" render-function="render"
|
||||
content-type="text/plain" charset="ISO-8859-1"
|
||||
resource-loader-path="classpath:" shared-engine="false">
|
||||
<mvc:script location="org/springframework/web/servlet/view/script/nashorn/render.js" />
|
||||
<mvc:script location="org/springframework/web/servlet/view/script/nashorn/render.js"/>
|
||||
</mvc:script-template-configurer>
|
||||
|
||||
</beans>
|
||||
|
|
Loading…
Reference in New Issue