extended checkResource(Locale) signature
This commit is contained in:
parent
2b13afd891
commit
68e07239c7
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
package org.springframework.web.servlet.view;
|
package org.springframework.web.servlet.view;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
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
|
* Check whether the underlying resource that the configured URL points to
|
||||||
* actually exists.
|
* actually exists.
|
||||||
|
* @param locale the desired Locale that we're looking for
|
||||||
* @return <code>true</code> if the resource exists (or is assumed to exist);
|
* @return <code>true</code> if the resource exists (or is assumed to exist);
|
||||||
* <code>false</code> if we know that it does not exist
|
* <code>false</code> if we know that it does not exist
|
||||||
* @throws Exception if the resource exists but is invalid (e.g. could not be parsed)
|
* @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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -418,7 +418,7 @@ public class UrlBasedViewResolver extends AbstractCachingViewResolver implements
|
||||||
protected View loadView(String viewName, Locale locale) throws Exception {
|
protected View loadView(String viewName, Locale locale) throws Exception {
|
||||||
AbstractUrlBasedView view = buildView(viewName);
|
AbstractUrlBasedView view = buildView(viewName);
|
||||||
View result = (View) getApplicationContext().getAutowireCapableBeanFactory().initializeBean(view, viewName);
|
View result = (View) getApplicationContext().getAutowireCapableBeanFactory().initializeBean(view, viewName);
|
||||||
return (view.checkResource() ? result : null);
|
return (view.checkResource(locale) ? result : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -197,10 +197,10 @@ public class FreeMarkerView extends AbstractTemplateView {
|
||||||
* multiple templates to be rendered into a single view.
|
* multiple templates to be rendered into a single view.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean checkResource() throws Exception {
|
public boolean checkResource(Locale locale) throws Exception {
|
||||||
try {
|
try {
|
||||||
// Check that we can get the template, even if we might subsequently get it again.
|
// Check that we can get the template, even if we might subsequently get it again.
|
||||||
getTemplate(getUrl(), getConfiguration().getLocale());
|
getTemplate(getUrl(), locale);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (FileNotFoundException ex) {
|
catch (FileNotFoundException ex) {
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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;
|
package org.springframework.web.servlet.view.velocity;
|
||||||
|
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
import java.util.Locale;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.apache.velocity.Template;
|
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.
|
* can be changed which may invalidate any early checking done here.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean checkResource() throws Exception {
|
public boolean checkResource(Locale locale) throws Exception {
|
||||||
if (!super.checkResource()) {
|
if (!super.checkResource(locale)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -253,7 +253,7 @@ public class VelocityView extends AbstractTemplateView {
|
||||||
* multiple templates to be rendered into a single view.
|
* multiple templates to be rendered into a single view.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean checkResource() throws Exception {
|
public boolean checkResource(Locale locale) throws Exception {
|
||||||
try {
|
try {
|
||||||
// Check that we can get the template, even if we might subsequently get it again.
|
// Check that we can get the template, even if we might subsequently get it again.
|
||||||
this.template = getTemplate(getUrl());
|
this.template = getTemplate(getUrl());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue