|
From: SimonG <Sim...@gm...> - 2004-04-11 22:03:07
|
BeanWrapperImpl javadoc states that applications can register PropertyEditors either on PropertyEditorManager or by means of registerCustomEditor(). I see two problems with the current functionality: 1) PropertyEditorManager: First of all, this might not be an option in a restircted environment. Also it only provides the possibility to specify a PropertyEditor per type, and not per property. 2) custom editor: Potentially many BeanWrapperImpl instances have to be "initialized" with PropertyEditors, especially if different bean hierarchies are used. As the BeanWrapper already uses PropertyEditors anyway, we could consult the wrapped bean's PropertyEditor in it's doFindCustomEditor() method like this: PropertyDescriptor propertyDescriptor = getPropertyDescriptor(propertyName); Class editorClass = propertyDescriptor.getPropertyEditorClass(); ... This approach is not completely satisfying though for two reasons: 1) only classes and no (customizable) instances of PropertyEditors can be registered 2) it uses a singleton registry (which is even shared by all applications in a container environment) I think it would be very useful if one could pass a configuration object to the BeanWrapperImpl, from where it could find out which PropertyEditors to use for which class and property. If the mapping of property to PropertyEditor would be independent of the property-path, this configuration object could even be used for all BeanWrapperImpls independent of the type of their "wrapped bean". Wonder what you think Simon -- NEU : GMX Internet.FreeDSL Ab sofort DSL-Tarif ohne Grundgebühr: http://www.gmx.net/info |