Late Binding

SWT Designer allows you to create the views, editors, perspectives, pref pages, composites, etc. that comprise Eclipse SWT & RCP applications and plug-ins.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

Late Binding

Postby davidallen » Mon Oct 26, 2009 12:18 am

I have the following scenario:

A table composite. The table binds to a a container model object.
A detail composite. The detail composite has a controller which binds its contents to an instance variable in the controller.
I created an instance variable in the table class that refers back to the controller. The controller is bound to the table selection.

My issue is the code generator is inserting code to init bindings at the close of the constructor in the table view. Since the detail component is not yet built, an NPE is thrown in the attempt to bind the controller field to the table selection. I have manually moved the call to an appropriate method - initing bindings only after the controller is set in the table composite.

Is there a mechanism to "inform" the generator of this scenario or a better method of defining bindings to avoid this? While the PhoneBook example includes a composite for the detail view - the actual example does not use this composite.
davidallen
 
Posts: 13
Joined: Fri Oct 16, 2009 7:45 pm

Re: Late Binding

Postby Eric Clayberg » Mon Oct 26, 2009 4:38 am

davidallen wrote:While the PhoneBook example includes a composite for the detail view - the actual example does not use this composite.

The data binding example code we provide does use this composite.

See the PhoneBookDetailComposite class and the PhoneBookUsingDetailComposite class. That show one pattern you can use.

You could also pass the controller in via the Composite's constructor as another alternative.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to SWT Designer

Who is online

Users browsing this forum: Google [Bot] and 2 guests