Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GWT Composite best practices

Tags:

composite

gwt

I'm learning GWT and have started to get the hang of it. I'm at the point where my code is getting to be a spaghetti mess so I'm going back and factoring reasonable bits of it out as Composites. The first problem I ran into was that my tool support failed to give the new Composite class an initWidget() method. It did include a default constructor.
For the time being, I've simply filled in my overridden initWidget() method with a call to super(initWidget(w)) My project compiles and runs as expected, though I feel as though I must be missing something.

What should I keep in mind when overriding init and what if anything do i need to place in the constructor. Is there anything else that I need to know or does it just boil down to regular old Java after this?

Clarification - It has occurred to me that there are probably different answers to this question depending on whether you intend to release said Composite classes as part of a library or simply part of your stand-alone app. I in particular have no intention at this time of developing externally useful components (mainly because I'm so green in this particular technology.)

Thanks!

like image 360
Brian Sweeney Avatar asked Feb 16 '09 05:02

Brian Sweeney


1 Answers

I'm not sure if I understand what you are trying to do. But for all the Composite's I've written I've never overridden the initWidget method. Because Composite itself doesn't need to be initialized with a constructor, i.e. no need to call super() my constructors of widgets extending composite look something like:

public mywidget() {
  SomePanel p = new SomePanel();
  ....
  initWidget(p);
}

As a best practice, imo, only the widget extending Composite should call it's 'own' initWidget.

like image 197
Hilbrand Bouwkamp Avatar answered Oct 16 '22 01:10

Hilbrand Bouwkamp