Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Strongly typed databinding?
Strongly typed databinding? [message #534092] Tue, 18 May 2010 01:23 Go to next message
Ken is currently offline Ken
Messages: 36
Registered: July 2009
Member
Is there a way to have more strongly typed databinding? Right now I have
something like using the eclipse.core.databinding package:

PojoObservables.observeValue(this.personModel, "name");

But if the name attribute (getName method) changes to firstName
(getFirstName) for example, I would not know until runtime that there is an
error.

My model is a JAXB created one.

- Ken
Re: Strongly typed databinding? [message #534116 is a reply to message #534092] Tue, 18 May 2010 07:01 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5422
Registered: July 2009
Senior Member
Hi,

No because Java doesn't have a concept of Properties. There are 2
solutions coming to my mind:

a) you create property constants when your model is generated from JAXB
(not sure if JAXB supports this) so you'd write something like this:
----------8<----------
PojoObservables.observeValue(this.personModel, Person.NAME);
----------8<----------
Which would lead to a compiler error if you regenerate.

b) you use EMF instead of JAXB because EMF generates such property
constants

Tom

Am 18.05.10 03:23, schrieb Ken Prole:
> Is there a way to have more strongly typed databinding? Right now I have
> something like using the eclipse.core.databinding package:
>
> PojoObservables.observeValue(this.personModel, "name");
>
> But if the name attribute (getName method) changes to firstName
> (getFirstName) for example, I would not know until runtime that there is
> an error.
>
> My model is a JAXB created one.
>
> - Ken
>
Re: Strongly typed databinding? [message #534702 is a reply to message #534116] Thu, 20 May 2010 03:52 Go to previous message
Ken is currently offline Ken
Messages: 36
Registered: July 2009
Member
Tom, thanks that make sense. Thanks for your pointers.

- Ken

"Tom Schindl" <tom.schindl@bestsolution.at> wrote in message
news:hste1g$p0m$1@build.eclipse.org...
> Hi,
>
> No because Java doesn't have a concept of Properties. There are 2
> solutions coming to my mind:
>
> a) you create property constants when your model is generated from JAXB
> (not sure if JAXB supports this) so you'd write something like this:
> ----------8<----------
> PojoObservables.observeValue(this.personModel, Person.NAME);
> ----------8<----------
> Which would lead to a compiler error if you regenerate.
>
> b) you use EMF instead of JAXB because EMF generates such property
> constants
>
> Tom
>
> Am 18.05.10 03:23, schrieb Ken Prole:
>> Is there a way to have more strongly typed databinding? Right now I have
>> something like using the eclipse.core.databinding package:
>>
>> PojoObservables.observeValue(this.personModel, "name");
>>
>> But if the name attribute (getName method) changes to firstName
>> (getFirstName) for example, I would not know until runtime that there is
>> an error.
>>
>> My model is a JAXB created one.
>>
>> - Ken
>>
>
Previous Topic:ALT+F4
Next Topic:Accessing the extensions for an (active) editor
Goto Forum:
  


Current Time: Fri Oct 24 23:53:34 GMT 2014

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

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