Browse Source

Tiles 3 TilesViewResolver allows for specifying custom TilesView subclasses as well

Issue: SPR-12075
pull/621/head
Juergen Hoeller 10 years ago
parent
commit
7c57424b48
  1. 24
      spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles3/TilesViewResolver.java

24
spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles3/TilesViewResolver.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 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.
@ -13,9 +13,11 @@ @@ -13,9 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.web.servlet.view.tiles3;
import org.apache.tiles.request.render.Renderer;
import org.springframework.web.servlet.view.UrlBasedViewResolver;
/**
@ -24,6 +26,7 @@ import org.springframework.web.servlet.view.UrlBasedViewResolver; @@ -24,6 +26,7 @@ import org.springframework.web.servlet.view.UrlBasedViewResolver;
*
* @author Nicolas Le Bas
* @author Rossen Stoyanchev
* @author Juergen Hoeller
* @since 3.2
*/
public class TilesViewResolver extends UrlBasedViewResolver {
@ -31,24 +34,35 @@ public class TilesViewResolver extends UrlBasedViewResolver { @@ -31,24 +34,35 @@ public class TilesViewResolver extends UrlBasedViewResolver {
private Renderer renderer;
public TilesViewResolver() {
setViewClass(requiredViewClass());
}
/**
* Requires {@link TilesView}.
*/
@Override
protected Class<?> getViewClass() {
protected Class<?> requiredViewClass() {
return TilesView.class;
}
/**
* Set the {@link Renderer} to use. If not set, by default
* {@link org.apache.tiles.renderer.DefinitionRenderer} is used.
* Set the {@link Renderer} to use. If not specified, a default
* {@link org.apache.tiles.renderer.DefinitionRenderer} will be used.
* @see TilesView#setRenderer(Renderer)
*/
public void setRenderer(Renderer renderer) {
this.renderer = renderer;
}
@Override
protected TilesView buildView(String viewName) throws Exception {
TilesView view = (TilesView) super.buildView(viewName);
view.setRenderer(this.renderer);
if (this.renderer != null) {
view.setRenderer(this.renderer);
}
return view;
}

Loading…
Cancel
Save