[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform] Re: Binding the attribute of a bean object wrapped in a WritableValue object

That could be the problem. Try this:

IObservableValue bindedNameTextObserveWidget = SWTObservables.observeText(text, SWT.Modify);

Matthew

Ovidio Mallo wrote:
Hi Hao,

are you binding the "name" attribute to an SWT Text instance (and not
a Label or so)? If so, SWTObservables#observeText(Control) is the wrong
method as it does not apply to Text instances. Instead, you should use
the method SWTObservables#observeText(Control, int). In the methods'
JavaDoc you can see which controls are supported by the individual
methods.

However, using the wrong method above should result in an exception being
thrown so maybe this is not your problem...

Regards,
Ovidio

Hao wrote:
I have a java bean such as Contact which has attributes such as name, address, email. The object presented to my code is a Wrapped WritableValue object, i.e. IObservableValue. For instance,
IObservableValue contactObservable = new WritableValue(new Contact(), Contact.class);


I tried to bind the name attributed of Contact bean wrapped in contactObservable to a text field. I did the following:

IObservableValue bindedNameTextObserveWidget = SWTObservables.observeText(text);
IObservableValue selectedContactNameObserveDetailValue = BeansObservables.observeDetailValue(Realm.getDefault(), contactObservable, "name", java.lang.String.class);


bindingContext.bindValue(bindedNameTextObserveWidget, contactObservable, null, null);

I did not get any error but this kind of binding does not work.

Any one knows how to bind the attribute of a writableValue object to a gui field instead of binding the attribute of a java bean to a gui field.