Forgive me if my question is too naive as I just started working with gwt.
I create a gwt module (let’s say Editor_A) which has a number of DataGrid, buttons, etc. It works fine in the web page.
Then I am about to create the 2nd gwt module Editor_B.
They will not be on the same page ever, however, Editor_B is very similar with Editor_A as it just has an extra table and a button.
Now of course, I don’t want to copy/paste code from Editor_A to Editor_B. Instead, I wish to reuse the code from Editor_A.
How can I do that?
How can I inherit from Editor_A and reuse most of its code with some modification to produce Editor_B?
This can solve your problem:
You can create an additional Core module, which is responsible for your base custom widgets, Client-Side Utils etc. Then you should inherit Core module in your both modules. So in your case you can create Composite widget which is used by
Editor_A, then in your latter module you can create yourEditor_Bby inheriting fromEditor_A. And of course you can add some modifications to that fromEditor_Bclass.If you are using they in the same module, you can create one BaseEditor which is Editor_A in your case. And then:
Apart from Java Inheritance be sure to configure GWT modules in the appropriate way, else the GWT Java to Javascript compiler will not find the relevant classes. Do this by modifying the module XML configuration to be something like this: