Unstable Terrain

Software development in the real world

Property Editors Part 2

with one comment

My previous post showed how to use a custom PropertyEditor to adapt strings to any class (in this case, Class files) when using JavaBean properties.

Turns out Spring already has a ClassEditor, and has since 2003.

All you have to do is wire it up:

<pre><bean id="customEditorConfigurer"
    <property name="customEditors">
            <entry key="java.lang.Class">
                <bean class="org.springframework.beans.propertyeditors.ClassEditor"/>

although it’s probably better to write a PropertyEditorRegistrar if you wanted to be forward-compatible.

Note to self: Don’t reinvent the wheel.


Written by Trent

December 27, 2009 at 11:48 am

Posted in Software Development

Tagged with ,

One Response

Subscribe to comments with RSS.

  1. […] how to do it properly. Possibly related posts: (automatically generated)Property Editors Part 2Saving/Retrieving the java […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: