Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » [Databinding] binding to objects attributes
[Databinding] binding to objects attributes [message #13379] Wed, 10 June 2009 12:32 Go to next message
Lars Vogel is currently offline Lars VogelFriend
Messages: 1098
Registered: July 2009
Senior Member

Hi,

is it possible to bind to attributes of objects within objects?

E.g. I have an Object Person with the attributes:

String firstName;
String lastName;
Address address;

where Address is an object with the attribute:

String street;

Can I bind direct to street via the person object? Something like this:

BeansObservables.observeValue(person, "address.street");

Or do I to use

BeansObservables.observeValue(person.getAddress(), "street");

Best regards, Lars
Re: [Databinding] binding to objects attributes [message #13400 is a reply to message #13379] Wed, 10 June 2009 12:45 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

With 3.4 you need to do this your own
-----------8<-----------
IObservable parent = BeansObservables.observeValue(person,"address");
IObservableValue child =
BeansObservables.observeDetail(parent,"street",Person.class);
-----------8<-----------

With 3.5 this works out of the box (when using Properties-API):

-----------8<-----------
IObservableValue v = BeanProperties.value("address.street").observe(person);
-----------8<-----------

You can read some details in my current blog. I'm discussing this at
EMF-Level but the code is the same for Beans. The nice thing with 3.5 is
that this even works in Table/Trees :-)

Tom

[1] http://tomsondev.bestsolution.at/2009/06/07/galileo-emf-data binding-part-2/

Lars Vogel schrieb:
> Hi,
>
> is it possible to bind to attributes of objects within objects?
>
> E.g. I have an Object Person with the attributes:
>
> String firstName;
> String lastName;
> Address address;
>
> where Address is an object with the attribute:
>
> String street;
>
> Can I bind direct to street via the person object? Something like this:
>
> BeansObservables.observeValue(person, "address.street");
>
> Or do I to use
>
> BeansObservables.observeValue(person.getAddress(), "street");
>
> Best regards, Lars
>
Re: [Databinding] binding to objects attributes [message #14063 is a reply to message #13400] Wed, 10 June 2009 14:33 Go to previous messageGo to next message
Lars Vogel is currently offline Lars VogelFriend
Messages: 1098
Registered: July 2009
Senior Member

Hi Tom,

xool, this is a nice feature in Eclipse 3.5.

I'll add a beans example to my databinding tutorial and put your blog
entries as references into it:
http://www.vogella.de/articles/EclipseDataBinding/article.ht ml

Thank you,

Lars


Tom Schindl wrote:
> Hi,
>
> With 3.4 you need to do this your own
> -----------8<-----------
> IObservable parent = BeansObservables.observeValue(person,"address");
> IObservableValue child =
> BeansObservables.observeDetail(parent,"street",Person.class);
> -----------8<-----------
>
> With 3.5 this works out of the box (when using Properties-API):
>
> -----------8<-----------
> IObservableValue v = BeanProperties.value("address.street").observe(person);
> -----------8<-----------
>
> You can read some details in my current blog. I'm discussing this at
> EMF-Level but the code is the same for Beans. The nice thing with 3.5 is
> that this even works in Table/Trees :-)
>
> Tom
>
> [1] http://tomsondev.bestsolution.at/2009/06/07/galileo-emf-data binding-part-2/
>
> Lars Vogel schrieb:
>> Hi,
>>
>> is it possible to bind to attributes of objects within objects?
>>
>> E.g. I have an Object Person with the attributes:
>>
>> String firstName;
>> String lastName;
>> Address address;
>>
>> where Address is an object with the attribute:
>>
>> String street;
>>
>> Can I bind direct to street via the person object? Something like this:
>>
>> BeansObservables.observeValue(person, "address.street");
>>
>> Or do I to use
>>
>> BeansObservables.observeValue(person.getAddress(), "street");
>>
>> Best regards, Lars
>>
Re: [Databinding] binding to objects attributes [message #14130 is a reply to message #13400] Wed, 10 June 2009 19:30 Go to previous messageGo to next message
Lars Vogel is currently offline Lars VogelFriend
Messages: 1098
Registered: July 2009
Senior Member

Hi Tom,

thanks again, I included a tiny bean example for the Properties API in
my tutorial.

Best regards, Lars

Tom Schindl wrote:
> Hi,
>
> With 3.4 you need to do this your own
> -----------8<-----------
> IObservable parent = BeansObservables.observeValue(person,"address");
> IObservableValue child =
> BeansObservables.observeDetail(parent,"street",Person.class);
> -----------8<-----------
>
> With 3.5 this works out of the box (when using Properties-API):
>
> -----------8<-----------
> IObservableValue v = BeanProperties.value("address.street").observe(person);
> -----------8<-----------
>
> You can read some details in my current blog. I'm discussing this at
> EMF-Level but the code is the same for Beans. The nice thing with 3.5 is
> that this even works in Table/Trees :-)
>
> Tom
>
> [1] http://tomsondev.bestsolution.at/2009/06/07/galileo-emf-data binding-part-2/
>
> Lars Vogel schrieb:
>> Hi,
>>
>> is it possible to bind to attributes of objects within objects?
>>
>> E.g. I have an Object Person with the attributes:
>>
>> String firstName;
>> String lastName;
>> Address address;
>>
>> where Address is an object with the attribute:
>>
>> String street;
>>
>> Can I bind direct to street via the person object? Something like this:
>>
>> BeansObservables.observeValue(person, "address.street");
>>
>> Or do I to use
>>
>> BeansObservables.observeValue(person.getAddress(), "street");
>>
>> Best regards, Lars
>>
Re: [Databinding] binding to objects attributes [message #14147 is a reply to message #14130] Wed, 10 June 2009 21:56 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

I just saw that there's a bug in my example :-) Naturally the second
line should be:

BeansObservables.observeDetail(parent,"street",Address.class);

Tom


Lars Vogel schrieb:
> Hi Tom,
>
> thanks again, I included a tiny bean example for the Properties API in
> my tutorial.
>
> Best regards, Lars
>
> Tom Schindl wrote:
>> Hi,
>>
>> With 3.4 you need to do this your own
>> -----------8<-----------
>> IObservable parent = BeansObservables.observeValue(person,"address");
>> IObservableValue child =
>> BeansObservables.observeDetail(parent,"street",Person.class);
>> -----------8<-----------
>>
>> With 3.5 this works out of the box (when using Properties-API):
>>
>> -----------8<-----------
>> IObservableValue v =
>> BeanProperties.value("address.street").observe(person);
>> -----------8<-----------
>>
>> You can read some details in my current blog. I'm discussing this at
>> EMF-Level but the code is the same for Beans. The nice thing with 3.5 is
>> that this even works in Table/Trees :-)
>>
>> Tom
>>
>> [1] http://tomsondev.bestsolution.at/2009/06/07/galileo-emf-data binding-part-2/
>>
>>
>> Lars Vogel schrieb:
>>> Hi,
>>>
>>> is it possible to bind to attributes of objects within objects?
>>>
>>> E.g. I have an Object Person with the attributes:
>>>
>>> String firstName;
>>> String lastName;
>>> Address address;
>>>
>>> where Address is an object with the attribute:
>>>
>>> String street;
>>>
>>> Can I bind direct to street via the person object? Something like this:
>>>
>>> BeansObservables.observeValue(person, "address.street");
>>>
>>> Or do I to use
>>>
>>> BeansObservables.observeValue(person.getAddress(), "street");
>>>
>>> Best regards, Lars
>>>
Previous Topic:[DataBinding] WizardScreen not fully updated
Next Topic:Issue with EditingSupport#canEdit
Goto Forum:
  


Current Time: Fri Apr 26 16:48:49 GMT 2024

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

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

Back to the top