[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform] Re: [DataBinding] Strange Behavior when binding to a combo

Thanks Matthew, that did it.
Regards,
Ali

Matthew Hall wrote:
Ali Naddaf wrote:
Hello All.

I posted a question a day ago and later on noticed that in fact the issue was had a different nature so here is my new problem. Let say I have the following snippet where I am binding the "name" field of the bean "ss" to a Combo called combo: ("dbc" is my databinding context)

-------------------
ss.setName("one");
combo= new Combo(group, SWT.NONE);
combo.setItems(new String[]{"", "one", "two"});
dbc.bindValue(SWTObservables.observeSelection(combo),
    BeansObservables.observeValue(ss, "name"), null, null);
------------------

When I run this, I will see "one" in the combo, as expected. However, at this moment, if I select "" (i.e. the empty selection) in the combo, the model (i.e. the "name" field in ss) doesn't get updated. If, on the other hand, I add the following line to the end of the above snippet, then all works as expected:

combo.setText(ss.getName());

Could someone please tell me what I am missing here?

Many thanks
Ali.


Try observeText instead of observeSelection.

Matthew