Re: [databinding] bind to a null EReference [message #331354] |
Wed, 03 September 2008 12:47 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
Hi Lusso,
Let's give it a try. Does your model look like this?
Person
+ address: Address
+ street: String
And you want to bind address.street? But it is possible that address is
null and you expect that if someone is entering a text in the TextField
a new Address-instance is created and its street value is filled?
If that's the case then no sorry this is *not possible* because
Databinding has no idea how to create the Address-Instance (it might not
even know/has access to the implementation-class because EMF is only
presenting the interface from the out side and OSGi is hidding the
implementation).
Still I think you can work around this using a trick like this:
Person
+ address: Address
+ street: String
+ addressStreet: String (volatile transient derived feature)
+ ... => other attributes of the none mandatory address-attributes
The trick shown here is a very cool one and I used it a e.g. for the
following problem.
Person
+ addresses: EList<Address>
+ homeAddress: Address (volatile transient derived feature)
+ billingAddress: Address (volatile transient derived feature)
So EMF makes this fairly easy but even with any other Model-Technology ;-)
Maybe I should write a small example for the Databinding-Snippet pages
using Standard Beans (or anyone else eager on doing so).
Tom
Ed Merks schrieb:
> Lusso,
>
> It seems like a relatively common type of situation. Unfortunately my
> data binding skills are close to zero, so I'm hoping Tom or someone else
> will see your question, which is more of a general data binding question
> than a specific-EMF one, and provide some guidance...
>
>
> Luca Lusso wrote:
>> Hi, I have a model object with a optional reference to an other model
>> object. Sometimes this reference is NULL because it's optional. In my
>> GUI what I want to do is bind some attribute of the optional reference
>> to text field. Is possible to use databinding in such a way that, when
>> user fill those fields, the referenced object will be created, filled
>> with correct data and attached to parent model object? I think I have
>> to write custom code to do so, and I'm looking for suggestion.
>>
>> Thanks
>>
>> Lusso Luca
--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
|
|
|
|
|
Re: [databinding] bind to a null EReference [message #331414 is a reply to message #331354] |
Fri, 05 September 2008 07:55 |
Eclipse User |
|
|
|
Originally posted by: axel.nitert.de
Hi Tom,
thanks for this example. It really helped me to save a lot of time. I
would like to suggest to include this into your example application.
I didn't have the time yet to test your example application but I will
do so soon. I am very curiour on the CDO part.
Axel
|
|
|
|
Re: [databinding] bind to a null EReference [message #331418 is a reply to message #331415] |
Fri, 05 September 2008 11:22 |
Eclipse User |
|
|
|
Originally posted by: axel.nitert.de
Hi Tom,
I thought about the data model and it seems that the example is not
quite correct compared to the reality.
The data structure should be like
FIFA (world-wide)
UEFA (Europe)
DFB (Germany)
What I mean is that the class Country should be a specialization of a
class like Region.
Region
Country
World
Continent
or something like this.
I didn't want to be pedantic it's just a remark.
Axel
Tom Schindl schrieb:
> Hi Axel,
>
> Good I idea. I'll add such a thing to the example application. The CDO
> thing is in fact so straight forward because all the real magic happens
> inside this framework. The only thing I had to figure out was how to
> make create connect to the server and for this problem there are great
> snippets available.
>
> Tom
>
> Axel Nitert schrieb:
>> Hi Tom,
>>
>> thanks for this example. It really helped me to save a lot of time. I
>> would like to suggest to include this into your example application.
>>
>> I didn't have the time yet to test your example application but I will
>> do so soon. I am very curiour on the CDO part.
>>
>> Axel
>
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.03255 seconds