ntumba lobo wrote:Well if you load your property files with Spring, you can use a new annotation to inject value from property file in teh field of a Java class
Load the property file in the Spring Context with
<util:properties id="myProperties"
location="classpath:/myprops.properties" />
or
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value=":/myprops.properties" />
</bean>
Then in a Java class
@Value("#{myProperties[myPropName]}")
private String myField;
or if you have only one property file
@Value("#{myPropName}")
private String myField;
Hope that helps
Wow, this is soooo close. THANK YOU!
However, from my code sample above, after I successfully declare the util in applicationContext.xml, if I try to do something like this:
in my domain class and then purposefully add some garbage characters.
Then, I just get the literal in the output #(errorProps[name])
That is, it's not de-referenced to show the actual message from the properties file.
The definition in the applicationContext.xml file is this:
The "name" key in the properties file should print the message: "Name is required."
Any idea what's still wrong?
Is it possible that the message tag doesn't support what I'm trying to do?
thanks again for any other suggestions.
-mike