Showing posts with label BeansObservables. Show all posts
Showing posts with label BeansObservables. Show all posts

Wednesday, October 31, 2007

Getting rid of those pesky "Could not attach listener to " log messages

If you've ever received...

Could not attach listener to org.eclipse.jface.examples.databinding.snippets.Snippet000HelloWorld$Person@92668c
java.lang.NoSuchMethodException: org.eclipse.jface.examples.databinding.snippets.Snippet000HelloWorld$Person.addPropertyChangeListener(java.beans.PropertyChangeListener)
at java.lang.Class.getMethod(Class.java:986)
...

and then asked...
"Why is this exception being logged?"

and we said...
"Because your object is not a Bean."

and you said...
"Correct. But I don't want that logged."

and we said...
"Well, if it's not a Bean then BeanObservables might not be the correct thing for you."

and you said...
"So what is the correct thing for me?"

and we said...
"It doesn't exist. Roll your own."

and you said...
"!@#$%^%@#$%!"

We heard your cries and created PojoObservables. It does everything that BeansObservables does except that it doesn't register PropertyChangeListeners. As a result it won't respond to changes in the POJO but it provides IObservable* implementations to be used in Bindings. It makes its first appearance in 3.4M3 as a result of bug 198201.

Monday, February 19, 2007

BeansObservables and registering for PropertyChangeEvents

In the past we've been a bit inconsistent about how BeansObservables registered for PropertyChangeEvents. In some cases we'd look for the addPropertyChangeListener(...) method that accepted the name of the property and in others cases we didn't. In order to ensure that your bean worked in all scenarios you had to implement both. As of this weekend we now abide by the bean spec (see section 7.4.1 and 7.4.5) in all cases. We look for the optional, with name, version first but fall back to the unnamed version if it is not found. Also if neither is found a warning is logged with the intention of making issues easier to debug.