List of usage examples for org.springframework.context.support MessageSourceResourceBundle MessageSourceResourceBundle
public MessageSourceResourceBundle(MessageSource source, Locale locale)
From source file:org.molasdin.wbase.jsf.spring.messages.JSFMessagesFactoryBean.java
public ResourceBundle getObject() throws Exception { //TODO: investigate issue with the early access FacesContext context = FacesContext.getCurrentInstance(); Locale locale = context.getViewRoot().getLocale(); return new MessageSourceResourceBundle(source, locale); }
From source file:org.web4thejob.orm.validation.MessageSourceResourceBundleLocator.java
public ResourceBundle getResourceBundle(Locale locale) { return new MessageSourceResourceBundle(this.messageSource, locale); }
From source file:se.trillian.goodies.stripes.localization.MessageSourceLocalizationBundleFactory.java
public ResourceBundle getErrorMessageBundle(Locale locale) throws MissingResourceException { return new MessageSourceResourceBundle(errorMessageSource, locale); }
From source file:se.trillian.goodies.stripes.localization.MessageSourceLocalizationBundleFactory.java
public ResourceBundle getFormFieldBundle(Locale locale) throws MissingResourceException { return new MessageSourceResourceBundle(formFieldMessageSource, locale); }
From source file:com.qcadoo.report.internal.ReportServiceImpl.java
private byte[] generateReport(final JasperReport template, final ReportType type, final Map<String, Object> parameters, final Locale locale) throws ReportException { Session session = null;//from w ww . j ava2s. com try { session = sessionFactory.openSession(); parameters.put(JRParameter.REPORT_LOCALE, locale); parameters.put("Author", pdfHelper.getDocumentAuthor()); parameters.put(JRHibernateQueryExecuterFactory.PARAMETER_HIBERNATE_SESSION, session); ResourceBundle resourceBundle = new MessageSourceResourceBundle(messageSource, locale); parameters.put(JRParameter.REPORT_RESOURCE_BUNDLE, resourceBundle); parameters.put(JRParameter.REPORT_FORMAT_FACTORY, new ReportFormatFactory()); JasperPrint jasperPrint = JasperFillManager.fillReport(template, parameters); JRExporter exporter = getExporter(type); ByteArrayOutputStream stream = new ByteArrayOutputStream(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, stream); exporter.exportReport(); return stream.toByteArray(); } catch (JRException e) { throw new ReportException(ReportException.Type.GENERATE_REPORT_EXCEPTION, e); } finally { if (session != null) { session.close(); } } }
From source file:ua.com.manometer.jasperreports.AbstractJasperReportsView.java
/** * 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</code> method. * @see org.springframework.web.servlet.support.RequestContextUtils#getLocale * @see org.springframework.context.support.MessageSourceResourceBundle * @see #getApplicationContext()/*from ww w . j av a 2 s . c o m*/ * @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()); if (!model.containsKey(JRParameter.REPORT_LOCALE)) { model.put(JRParameter.REPORT_LOCALE, rc.getLocale()); } 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(), rc.getLocale())); } }