Announcement Announcement Module
Collapse
No announcement yet.
Parameterizing MessageSource Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Parameterizing MessageSource

    I need to define a MessageSource whose baseName needs to
    be parameterized using a propertyConfigurer. I would like to
    know how I can parameterize a list of baseNames (hypothetically)
    as follows:

    Code:
    	<bean id="propertyConfigurer"
    		class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    		init-method="initializeBean">
    
    		
    		<!-- If you cannot resolve the parameter in (...), 
    			look for it in the classpath resources.
    		-->
    		<property name="searchClasspathResources">
    			<value>true</value>
    		</property>
    
    		<!-- If you cannot resolve the parameter in classpath resources as well, 
    			look for it in the system environment.
    		-->
    		<property name="searchSystemEnvironment">
    			<value>true</value>
    		</property>
    
    		<!-- If you have to search the system environment, do it as a last resort (as opposed
    			to having it override the class path properties -->
    		<property name="systemPropertiesModeName">
    			<value>SYSTEM_PROPERTIES_MODE_FALLBACK</value>
    		</property>
    	</bean>
    
    
     <bean id="messageSource"
            class="org.springframework.context.support.ResourceBundleMessageSource">
        <property name="basenames">
          <list>
               ${list.of.mybasenames}
          </list>
        </property>
      </bean>
    where, property "list.of.mybasenames" is defined in a property file loaded
    by PropertConfigurer:

    Code:
     C:\> type myapp.properties
     list.of.mybasenames: ui_messages, db_messages, backend_messages
    In short, how can I parameterize a list of strings and pass them as basenames to MessageSource?

    Thanks

    /U

  • #2
    Have you tried this an it didn't work? I would have thought something like this would work fine. All you need it a CSV property editor.
    Code:
    list.of.mybasenames=ui_messages,db_messages,backend_messages
    http://www.springframework.org/docs/...rtyEditor.html

    Comment

    Working...
    X