From 68e07239c76d337038062d6d36463349298732f2 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 8 Jul 2009 13:37:27 +0000 Subject: [PATCH] extended checkResource(Locale) signature --- .../web/servlet/view/AbstractUrlBasedView.java | 5 ++++- .../web/servlet/view/UrlBasedViewResolver.java | 2 +- .../web/servlet/view/freemarker/FreeMarkerView.java | 4 ++-- .../web/servlet/view/velocity/VelocityLayoutView.java | 7 ++++--- .../web/servlet/view/velocity/VelocityView.java | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/AbstractUrlBasedView.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/AbstractUrlBasedView.java index 7ed61933eb..c6be1fc9fb 100644 --- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/AbstractUrlBasedView.java +++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/AbstractUrlBasedView.java @@ -16,6 +16,8 @@ package org.springframework.web.servlet.view; +import java.util.Locale; + import org.springframework.beans.factory.InitializingBean; /** @@ -78,11 +80,12 @@ public abstract class AbstractUrlBasedView extends AbstractView implements Initi /** * Check whether the underlying resource that the configured URL points to * actually exists. + * @param locale the desired Locale that we're looking for * @return true if the resource exists (or is assumed to exist); * false if we know that it does not exist * @throws Exception if the resource exists but is invalid (e.g. could not be parsed) */ - public boolean checkResource() throws Exception { + public boolean checkResource(Locale locale) throws Exception { return true; } diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/UrlBasedViewResolver.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/UrlBasedViewResolver.java index c7674a6930..f3933fbf50 100644 --- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/UrlBasedViewResolver.java +++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/UrlBasedViewResolver.java @@ -418,7 +418,7 @@ public class UrlBasedViewResolver extends AbstractCachingViewResolver implements protected View loadView(String viewName, Locale locale) throws Exception { AbstractUrlBasedView view = buildView(viewName); View result = (View) getApplicationContext().getAutowireCapableBeanFactory().initializeBean(view, viewName); - return (view.checkResource() ? result : null); + return (view.checkResource(locale) ? result : null); } /** diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/freemarker/FreeMarkerView.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/freemarker/FreeMarkerView.java index 9e88de553d..8f492adfda 100644 --- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/freemarker/FreeMarkerView.java +++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/freemarker/FreeMarkerView.java @@ -197,10 +197,10 @@ public class FreeMarkerView extends AbstractTemplateView { * multiple templates to be rendered into a single view. */ @Override - public boolean checkResource() throws Exception { + public boolean checkResource(Locale locale) throws Exception { try { // Check that we can get the template, even if we might subsequently get it again. - getTemplate(getUrl(), getConfiguration().getLocale()); + getTemplate(getUrl(), locale); return true; } catch (FileNotFoundException ex) { diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/velocity/VelocityLayoutView.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/velocity/VelocityLayoutView.java index dcb59a8ff3..3e8ac3d4fa 100644 --- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/velocity/VelocityLayoutView.java +++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/velocity/VelocityLayoutView.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2006 the original author or authors. + * Copyright 2002-2009 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. @@ -17,6 +17,7 @@ package org.springframework.web.servlet.view.velocity; import java.io.StringWriter; +import java.util.Locale; import javax.servlet.http.HttpServletResponse; import org.apache.velocity.Template; @@ -118,8 +119,8 @@ public class VelocityLayoutView extends VelocityToolboxView { * can be changed which may invalidate any early checking done here. */ @Override - public boolean checkResource() throws Exception { - if (!super.checkResource()) { + public boolean checkResource(Locale locale) throws Exception { + if (!super.checkResource(locale)) { return false; } diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/velocity/VelocityView.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/velocity/VelocityView.java index 5607ac876b..6699f514bb 100644 --- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/velocity/VelocityView.java +++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/velocity/VelocityView.java @@ -253,7 +253,7 @@ public class VelocityView extends AbstractTemplateView { * multiple templates to be rendered into a single view. */ @Override - public boolean checkResource() throws Exception { + public boolean checkResource(Locale locale) throws Exception { try { // Check that we can get the template, even if we might subsequently get it again. this.template = getTemplate(getUrl()); -- GitLab