spring-framework / org.springframework.beans.propertyeditors / ResourceBundleEditor

ResourceBundleEditor

open class ResourceBundleEditor : PropertyEditorSupport

java.beans.PropertyEditor implementation for standard JDK java.util.ResourceBundle.

Only supports conversion from a String, but not to a String. Find below some examples of using this class in a (properly configured) Spring container using XML-based metadata:

 <bean id="errorDialog" class="..."> <!-- the 'messages' property is of type java.util.ResourceBundle. the 'DialogMessages.properties' file exists at the root of the CLASSPATH --> <property name="messages" value="DialogMessages"/> </bean>
 <bean id="errorDialog" class="..."> <!-- the 'DialogMessages.properties' file exists in the 'com/messages' package --> <property name="messages" value="com/messages/DialogMessages"/> </bean>

A 'properly configured' Spring org.springframework.context.ApplicationContext might contain a org.springframework.beans.factory.config.CustomEditorConfigurer definition such that the conversion can be effected transparently:

 <bean class="org.springframework.beans.factory.config.CustomEditorConfigurer"> <property name="customEditors"> <map> <entry key="java.util.ResourceBundle"> <bean class="org.springframework.beans.propertyeditors.ResourceBundleEditor"/> </entry> </map> </property> </bean>

Please note that this java.beans.PropertyEditor is not registered by default with any of the Spring infrastructure.

Thanks to David Leal Valmana for the suggestion and initial prototype.

Author
Rick Evans

Author
Juergen Hoeller

Since
2.0

Constructors

<init>

ResourceBundleEditor()

java.beans.PropertyEditor implementation for standard JDK java.util.ResourceBundle.

Only supports conversion from a String, but not to a String. Find below some examples of using this class in a (properly configured) Spring container using XML-based metadata:

 <bean id="errorDialog" class="..."> <!-- the 'messages' property is of type java.util.ResourceBundle. the 'DialogMessages.properties' file exists at the root of the CLASSPATH --> <property name="messages" value="DialogMessages"/> </bean>
 <bean id="errorDialog" class="..."> <!-- the 'DialogMessages.properties' file exists in the 'com/messages' package --> <property name="messages" value="com/messages/DialogMessages"/> </bean>

A 'properly configured' Spring org.springframework.context.ApplicationContext might contain a org.springframework.beans.factory.config.CustomEditorConfigurer definition such that the conversion can be effected transparently:

 <bean class="org.springframework.beans.factory.config.CustomEditorConfigurer"> <property name="customEditors"> <map> <entry key="java.util.ResourceBundle"> <bean class="org.springframework.beans.propertyeditors.ResourceBundleEditor"/> </entry> </map> </property> </bean>

Please note that this java.beans.PropertyEditor is not registered by default with any of the Spring infrastructure.

Thanks to David Leal Valmana for the suggestion and initial prototype.

Properties

BASE_NAME_SEPARATOR

static val BASE_NAME_SEPARATOR: String

The separator used to distinguish between the base name and the locale (if any) when converting from a String.

Functions

setAsText

open fun setAsText(text: String): Unit