Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » [Databinding] databinding arrays and lists of strings
[Databinding] databinding arrays and lists of strings [message #326668] Thu, 27 March 2008 21:05 Go to next message
Jason Hocker is currently offline Jason HockerFriend
Messages: 43
Registered: July 2009
Member
I'm hoping I'm missing a basic understanding and you can help me out. I'm
new to using databinding.

I have a Person bean. That object has a string array of nicknames for the
person. In the GUI, I want a table to show this list of names.
Additionally, I want to add actions that can add or remove or change the
order. Right now I'm having trouble binding a table to this list property
of a Person object.

Can anyone help explain how binding works with lists?
Re: [Databinding] databinding arrays and lists of strings [message #326690 is a reply to message #326668] Fri, 28 March 2008 17:08 Go to previous message
Matthew Hall is currently offline Matthew HallFriend
Messages: 368
Registered: July 2009
Senior Member
Jay,

I'm assuming you're using BeansObservables.observeList(person,
"listProperty") to observe the array property--is this correct?

In order for DataBinding to pick up the change in your bean, you need to
implement the full bean spec in your bean class:

void addPropertyChangeListener(PropertyChangeListener listener)
void removePropertyChangeListener(PropertyChangeListener listener)
void addPropertyChangeListener(
String propertyName, PropertyChangeListener listener)
void removePropertyChangeListener(
String propertyName, PropertyChangeListener listener)

When the bean property changes, you need to fire a PropertyChangeEvent,
and in the case of collections, the event's oldValue and newValue must
be full copies of the old and new state of the array:

private PropertyChangeSupport changeSupport = new
PropertyChangeSupport(this);

public void setNicknames(String[] nicknames) {
// Do checks on argument, etc.

Object oldValue = this.nicknames;
this.nicknames = nicknames;
Object newValue = nicknames.clone(); // defensive copy
changeSupport.firePropertyChange("nicknames", oldValue, newValue);
}

When DataBinding receives the property change, it calculates the
difference between the old array and the new array, and updates the
IObservableList accordingly.

Let me know if you need more information.

Matthew

Jay Simpson wrote:
> I'm hoping I'm missing a basic understanding and you can help me out. I'm
> new to using databinding.
>
> I have a Person bean. That object has a string array of nicknames for the
> person. In the GUI, I want a table to show this list of names.
> Additionally, I want to add actions that can add or remove or change the
> order. Right now I'm having trouble binding a table to this list property
> of a Person object.
>
> Can anyone help explain how binding works with lists?
>
>
Previous Topic:Plugin Required-Bundle
Next Topic:[Databinding] testing
Goto Forum:
  


Current Time: Thu Dec 26 21:08:36 GMT 2024

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

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

Back to the top