Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Why is it needed for java bean to implement property change support
Why is it needed for java bean to implement property change support [message #328349] Thu, 22 May 2008 15:49 Go to next message
Hao Missing name is currently offline Hao Missing nameFriend
Messages: 115
Registered: July 2009
Senior Member
jface databinding framwork has provided a lot of help classes, such as
BeansObservables and WritableValue. Why is it still needed for java bean
to implement property change support, such as

public class Message extends ModelObject {
...
}

public class ModelObject {

private final PropertyChangeSupport propertyChangeSupport = new
PropertyChangeSupport(
this);

public void addPropertyChangeListener(PropertyChangeListener listener) {
propertyChangeSupport.addPropertyChangeListener(listener);
}

public void addPropertyChangeListener(String propertyName,
PropertyChangeListener listener) {
propertyChangeSupport.addPropertyChangeListener(propertyName , listener);
}

public void removePropertyChangeListener(PropertyChangeListener listener)
{
propertyChangeSupport.removePropertyChangeListener(listener) ;
}

public void removePropertyChangeListener(String propertyName,
PropertyChangeListener listener) {
propertyChangeSupport.removePropertyChangeListener(propertyN ame,
listener);
}

protected void firePropertyChange(String propertyName, Object oldValue,
Object newValue) {
propertyChangeSupport.firePropertyChange(propertyName, oldValue,
newValue);
}
protected void fireIndexedPropertyChange(String propertyName, int index,
Object oldValue, Object newValue) {
propertyChangeSupport.fireIndexedPropertyChange( propertyName, index,
oldValue, newValue);
}
}
Re: Why is it needed for java bean to implement property change support [message #328350 is a reply to message #328349] Thu, 22 May 2008 17:17 Go to previous messageGo to next message
Matthew Hall is currently offline Matthew HallFriend
Messages: 368
Registered: July 2009
Senior Member
hao wrote:
> jface databinding framwork has provided a lot of help classes, such as
> BeansObservables and WritableValue. Why is it still needed for java bean
> to implement property change support, such as
> <<snip>>

DataBinding is based around the observer pattern. If there is no
property change support on your bean, then BeansObservables has no way
to add property change listeners, and therefore cannot detect when your
bean properties change.

If property change support is not critical to your application, you can
use PojoObservables instead. PojoObservables are identical to
BeansObservables except that they do not use property change listeners.

Matthew
[DataBinding] Re: Why is it needed for java bean to implement property change support [message #328351 is a reply to message #328349] Thu, 22 May 2008 16:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse-news.rizzoweb.com

hao wrote:
> jface databinding framwork has provided a lot of help classes, such as
> BeansObservables and WritableValue. Why is it still needed for java bean
> to implement property change support

In Eclipse 3.4, there is a new class,
org.eclipse.core.databinding.beans.PojoObservables, that supports
creating observables on objects that do not fire property change events.
The limitation, of course, is that the framework isn't notified if the
underlying objects are changed directly - that's what the property
change events provide. So if your model objects don't do that they can't
tell the data binding framework when their properties have changed.

Hope this helps,
Eric
Re: [DataBinding] Re: Why is it needed for java bean to implement property change support [message #328355 is a reply to message #328351] Fri, 23 May 2008 01:00 Go to previous message
Hao Missing name is currently offline Hao Missing nameFriend
Messages: 115
Registered: July 2009
Senior Member
Thanks all of you!
Previous Topic:p2 Installer Issues
Next Topic:How to update an RCP app
Goto Forum:
  


Current Time: Sat Aug 31 23:32:17 GMT 2024

Powered by FUDForum. Page generated in 0.03813 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top