Results 1 to 3 of 3

Thread: Using a ResourceBundle in ApplicationContext.xml

  1. #1
    Join Date
    Feb 2009
    Location
    Sydney, Australia
    Posts
    8

    Question Using a ResourceBundle in ApplicationContext.xml

    Greetings,

    I was wondering, is there anyway to reference resource bundle text properties like "footer.company.name" in the actual Spring bean XML files i.e. like applicationContext.xml?

    I have the usual ApplicationResource.properties file with name/value pairs i.e.

    Code:
    footer.company.name=Your Company...
    I don't have a problem using them in a Facelets page e.g.
    Code:
    #{text['footer.company.name']}
    with the following loadBundle inside one of the XHTML files...

    Code:
    <f:loadBundle basename="ApplicationResources" var="text" />
    and the JSF faces-config.xml set to

    Code:
    <application><el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
    <locale-config>
    	<default-locale>en</default-locale>
    </locale-config>
    <message-bundle>ApplicationResources</message-bundle>
    </application>

  2. #2
    Join Date
    Oct 2008
    Location
    UK
    Posts
    8

    Default

    Just in case you still need it:

    HTML Code:
    <bean id="servicePropertyConfig" 
    	class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    	<property name="locations">
    		<list>
    			<value>classpath:properties-file-to-use.properties</value>
    			<value>classpath:another-properties-file-to-use.properties</value>
    		</list>
    	</property>
    	<property name="placeholderPrefix" value="$properties{"/>
    </bean>
    
    ....
    
    <bean id="beanWithAProperty"  class="foo.Class">
    	<property name="propertyToSet" value="$properties{property.from.bundle}"/>
    </bean>
    cheers,
    LK

  3. #3
    Join Date
    Feb 2009
    Location
    Sydney, Australia
    Posts
    8

    Default

    This worked perfectly btw (as you can tell by the delay in responding, it was a low priority to return to this ...

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •