Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I define a custom message source for a spring web flow?

The spring webflow documentation mentions that their way of adding messages to a flow is to define all messages regarding that flow in a file messages.properties inside the flow:

Internationalized messages are defined in message bundles accessed by a Spring MessageSource. To create a flow-specific message bundle, simply define messages.properties file(s) in your flow's directory. Create a default messages.properties file and a .properties file for each additional Locale you need to support.

In our webapp we use a mix of Spring Webflow and proprietary frameworks. We have all our internationalized messages in a single file and we'd like to have Spring Webflow access this one instead of littering our project with dozens of properties files. Is there a way to configure the message source for a spring webflow or are we stuck to messages.properties?

like image 809
Jan Thomä Avatar asked Nov 08 '11 10:11

Jan Thomä


1 Answers

Put something like this in your application context XML file:

<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
    <property name="basename"><value>classpath:yourSharedResourceBundle</value></property>
</bean>

As long as the file is located on the classpath it should be used.

like image 193
Scott A Avatar answered Oct 15 '22 10:10

Scott A