Skip to content

Commit

Permalink
Tiles 3 TilesViewResolver allows for specifying custom TilesView subc…
Browse files Browse the repository at this point in the history
…lasses as well

Issue: SPR-12075
(cherry picked from commit 7c57424)
  • Loading branch information
jhoeller committed Aug 11, 2014
1 parent 214f026 commit 6639320
Showing 1 changed file with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;

/**
Expand All @@ -24,32 +26,43 @@
*
* @author Nicolas Le Bas
* @author Rossen Stoyanchev
* @author Juergen Hoeller
* @since 3.2
*/
public class TilesViewResolver extends UrlBasedViewResolver {

private Renderer renderer;


public TilesViewResolver() {
setViewClass(requiredViewClass());
}


/**
* Requires {@link TilesView}.
*/
@Override
@SuppressWarnings("rawtypes")
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;
}

Expand Down

0 comments on commit 6639320

Please sign in to comment.