From d418eed56f6335f7729f75510b0cb632fc10910b Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 20 Oct 2010 05:22:43 +0000 Subject: [PATCH] AbstractJasperReportsView only sets locale model attributes if not present already --- .../view/jasperreports/AbstractJasperReportsView.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/jasperreports/AbstractJasperReportsView.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/jasperreports/AbstractJasperReportsView.java index 2db690a154..28b73bb5a2 100644 --- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/jasperreports/AbstractJasperReportsView.java +++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/jasperreports/AbstractJasperReportsView.java @@ -568,7 +568,7 @@ public abstract class AbstractJasperReportsView extends AbstractUrlBasedView { * Expose current Spring-managed Locale and MessageSource to JasperReports i18n * ($R expressions etc). The MessageSource should only be exposed as JasperReports * resource bundle if no such bundle is defined in the report itself. - *

Default implementation exposes the Spring RequestContext Locale and a + *

The default implementation exposes the Spring RequestContext Locale and a * MessageSourceResourceBundle adapter for the Spring ApplicationContext, * analogous to the JstlUtils.exposeLocalizationContext method. * @see org.springframework.web.servlet.support.RequestContextUtils#getLocale @@ -580,9 +580,12 @@ public abstract class AbstractJasperReportsView extends AbstractUrlBasedView { */ protected void exposeLocalizationContext(Map model, HttpServletRequest request) { RequestContext rc = new RequestContext(request, getServletContext()); - model.put(JRParameter.REPORT_LOCALE, rc.getLocale()); + if (!model.containsKey(JRParameter.REPORT_LOCALE)) { + model.put(JRParameter.REPORT_LOCALE, rc.getLocale()); + } JasperReport report = getReport(); - if (report == null || report.getResourceBundle() == null) { + if ((report == null || report.getResourceBundle() == null) && + !model.containsKey(JRParameter.REPORT_RESOURCE_BUNDLE)) { model.put(JRParameter.REPORT_RESOURCE_BUNDLE, new MessageSourceResourceBundle(rc.getMessageSource(), rc.getLocale())); }