-
Enhancement
-
Resolution: Fixed
-
P4
-
1.2.2
-
tiger
-
generic
-
generic
Name: krT82822 Date: 09/22/99
Sometimes it's not possible to create a new PropertyEditor simply
by invoking newInstance() on its class. In my designs, the
editor for a given property should really have some link to the
bean that its modifying. For example:
1 - A URLEditor class should accept both absolute and relative
urls. However, the context url depends on which bean is being
modified. (For example, if the bean is also an applet then
the context url might be the applet's documentBase property,
which will be different for different applet's)
2 - An editor which presents the user with a list of the fields
available from a database needs to know which database
to get its list from.
I beleive the problem can be remedied by adding the following
method to the PropertyDescriptor class:
public PropertyEditor createPropertyEditor(Object bean) { ... }
The createPropertyEditor method is a factory method for creating
PropertyEditors which can edit the property on behalf of the
given JavaBean. The bean argument allows the PropertyEditor to
retrieve some of its state from the bean.
The default implementation will first check to see if the
getPropertyEditorClass method returns a non-null. If it does, then
newInstance() will be called on it to create a new PropertyEditor.
Otherwise, PropertyEditorManager.findEditor will be used to find
a PropertyEditor for the declared type of this property. If
that fails, then it returns null.
(Review ID: 95596)
======================================================================
- relates to
-
JDK-7087876 java/beans/PropertyDescriptor.html#createPropertyEditor() throws RE if editor cannot be created
- Closed
-
JDK-6582164 JavaBeans tests should be open source
- Resolved