PropertyEditorManager limitation

A

Adam P. Jenkins

The few times I've thought of using PropertyEditors, I've run into what
seems like a serious limitation of PropertyEditorManager. I'm curious if
other people find this to be a serious limitation or not.

PropertyEditorManager allows PropertyEditors to be associated with
particular property types. However it does not allow a PropertyEditor to be
associated with a specific property of a bean class. That is, I can
register a PropertyEditor to be used for all properties of type
java.lang.String, but I can't register a PropertyEditor to be used for a
specific property of a specific bean class, which happens to be of type
String.

Suppose I have a Professor bean class which has a "department" property of
type java.lang.String, which must be set to one of a list of department
names. I'd like the PropertyEditor for this property to return an array of
allowable department names from its getTags() method. However
PropertyEditorManager gives me no way to implement this, other than changing
the PropertyEditor for all java.lang.String properties, or using a special
Department class as the property type so that I can register a
PropertyEditor for it.

I'm sure you can come up with other scenarios where you'd want to specify a
specialized customComponent or paintValue method for a specific bean
property, but not have it apply to all properties of that type in any bean.
Basically I'd like PropertyEditorManager to have these methods:

void registerEditor(Class beanType, String propertyName, Class
editorClass);
PropertyEditor findEditor(Class beanType, String propertyName);

To me this pretty much makes PropertyEditorManager useless for any real
application. Maybe for a toy application or something for internal use only
I'd be willing to use the same editor type for all bean properties of type
String or int or whatever, but normally I want to be able to specify a tags
list or custom component for at least some bean properties.

Just wondering how useful others find PropertyEditorManager to be in its
present form. Thanks for any comments.

Adam
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top