Prev: MAVEN TUTORIAL With ECLIPSE IDE
Next: dmd
From: Olaf Klischat on 22 Nov 2009 12:25 When providing a BeanInfo for a Java bean, is it possible to only provide a single custom PropertyDescriptor for one of the (dozens of) properties of the bean, and fall back to the JRE's default reflection discovery for all other properties? When looking at the BeanInfo spec, it seems to me that you can only either use the default discovery for all the properties or provide custom descriptors for all the properties; there appears to be no API to explicitly invoke the JRE's reflective property discovery and then replace just one of the resulting PropertyDescriptors with your own one.
From: EJP on 22 Nov 2009 17:48 Olaf Klischat wrote: > When providing a BeanInfo for a Java bean, is it possible to only > provide a single custom PropertyDescriptor for one of the (dozens of) > properties of the bean, and fall back to the JRE's default reflection > discovery for all other properties? Yes. You can call the Introspector again with a different argument that tells it to ignore the BeanInfo so you don't recurse.
From: Olaf Klischat on 23 Nov 2009 02:59 EJP wrote: > Olaf Klischat wrote: >> When providing a BeanInfo for a Java bean, is it possible to only >> provide a single custom PropertyDescriptor for one of the (dozens of) >> properties of the bean, and fall back to the JRE's default reflection >> discovery for all other properties? > > > Yes. You can call the Introspector again with a different argument that > tells it to ignore the BeanInfo so you don't recurse. Yeah, I found Introspector.getBeanInfo(Bean.class, IGNORE_IMMEDIATE_BEANINFO). Did you mean that? Unfortunately, this is available in 1.7 only, which I can't use. I think I got it to work (more or less) by calling Introspector.getBeanInfo() from getPropertyDescriptors() and returning null in the resulting recursive call to getPropertyDescriptors(), and then appropriately modifying the PropertyDescriptor[] array returned to the "outer" getPropertyDescriptors() invocation.
From: EJP on 23 Nov 2009 04:14 Olaf Klischat wrote: > Yeah, I found Introspector.getBeanInfo(Bean.class, > IGNORE_IMMEDIATE_BEANINFO). Did you mean that? Unfortunately, this is > available in 1.7 only, which I can't use. That's strange, it was available in 1.6 when I used it last June, and it's in the Javadoc for 1.5 and 1.4 and 1.3. So you are at least nine years out with that statement.
From: Olaf Klischat on 23 Nov 2009 17:43 EJP wrote: > Olaf Klischat wrote: >> Yeah, I found Introspector.getBeanInfo(Bean.class, >> IGNORE_IMMEDIATE_BEANINFO). Did you mean that? Unfortunately, this is >> available in 1.7 only, which I can't use. > > That's strange, it was available in 1.6 when I used it last June, and > it's in the Javadoc for 1.5 and 1.4 and 1.3. So you are at least nine > years out with that statement. Wow. You're right. I guess I was only looking at the getBeanInfo(Class,Class,int) method (which was introduced in 1.7) but failed to notice the getBeanInfo(Class,int) one. I'm sorry if I'm looking a bit like an idiot right now :-|
|
Pages: 1 Prev: MAVEN TUTORIAL With ECLIPSE IDE Next: dmd |