Java Code Examples for net.sf.jasperreports.engine.JasperReport#getResourceBundle()

The following examples show how to use net.sf.jasperreports.engine.JasperReport#getResourceBundle() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractJasperReportsView.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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.
 * <p>The default implementation exposes the Spring RequestContext Locale and a
 * MessageSourceResourceBundle adapter for the Spring ApplicationContext,
 * analogous to the {@code JstlUtils.exposeLocalizationContext} method.
 * @see org.springframework.web.servlet.support.RequestContextUtils#getLocale
 * @see org.springframework.context.support.MessageSourceResourceBundle
 * @see #getApplicationContext()
 * @see net.sf.jasperreports.engine.JRParameter#REPORT_LOCALE
 * @see net.sf.jasperreports.engine.JRParameter#REPORT_RESOURCE_BUNDLE
 * @see org.springframework.web.servlet.support.JstlUtils#exposeLocalizationContext
 */
protected void exposeLocalizationContext(Map<String, Object> model, HttpServletRequest request) {
	RequestContext rc = new RequestContext(request, getServletContext());
	Locale locale = rc.getLocale();
	if (!model.containsKey(JRParameter.REPORT_LOCALE)) {
		model.put(JRParameter.REPORT_LOCALE, locale);
	}
	TimeZone timeZone = rc.getTimeZone();
	if (timeZone != null && !model.containsKey(JRParameter.REPORT_TIME_ZONE)) {
		model.put(JRParameter.REPORT_TIME_ZONE, timeZone);
	}
	JasperReport report = getReport();
	if ((report == null || report.getResourceBundle() == null) &&
			!model.containsKey(JRParameter.REPORT_RESOURCE_BUNDLE)) {
		model.put(JRParameter.REPORT_RESOURCE_BUNDLE,
				new MessageSourceResourceBundle(rc.getMessageSource(), locale));
	}
}
 
Example 2
Source File: AbstractJasperReportsView.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * 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.
 * <p>The default implementation exposes the Spring RequestContext Locale and a
 * MessageSourceResourceBundle adapter for the Spring ApplicationContext,
 * analogous to the {@code JstlUtils.exposeLocalizationContext} method.
 * @see org.springframework.web.servlet.support.RequestContextUtils#getLocale
 * @see org.springframework.context.support.MessageSourceResourceBundle
 * @see #getApplicationContext()
 * @see net.sf.jasperreports.engine.JRParameter#REPORT_LOCALE
 * @see net.sf.jasperreports.engine.JRParameter#REPORT_RESOURCE_BUNDLE
 * @see org.springframework.web.servlet.support.JstlUtils#exposeLocalizationContext
 */
protected void exposeLocalizationContext(Map<String, Object> model, HttpServletRequest request) {
	RequestContext rc = new RequestContext(request, getServletContext());
	Locale locale = rc.getLocale();
	if (!model.containsKey(JRParameter.REPORT_LOCALE)) {
		model.put(JRParameter.REPORT_LOCALE, locale);
	}
	TimeZone timeZone = rc.getTimeZone();
	if (timeZone != null && !model.containsKey(JRParameter.REPORT_TIME_ZONE)) {
		model.put(JRParameter.REPORT_TIME_ZONE, timeZone);
	}
	JasperReport report = getReport();
	if ((report == null || report.getResourceBundle() == null) &&
			!model.containsKey(JRParameter.REPORT_RESOURCE_BUNDLE)) {
		model.put(JRParameter.REPORT_RESOURCE_BUNDLE,
				new MessageSourceResourceBundle(rc.getMessageSource(), locale));
	}
}