nitin verma
nitin verma

Reputation: 634

how to call a GWT module entry point class?

l split my GWT code in different different modules like

PrintPermit.gwt.xml

EmployeeResponse.gwt.xml

Rejected.gwt.xml

and every module has its own entry point class

in my HTML host page I am calling script like

ae.init.EmployeeResponse.nocache.js

I have a menu like

Print Application

Reject Application

New application

whenever user will click on new application default new application will open as I declare EmployeeResponse.nocache.js statically in my HTML host page.

now I want to call other modules on click button print and reject button

how can i call nocache js for print and reject modules. is there any way to dynamic call. please help me guys.

Upvotes: 1

Views: 902

Answers (3)

El Hoss
El Hoss

Reputation: 3832

There is a example of an InterAppEventBus:

https://github.com/sambathl/interapp-eventbus

which shows the communication between two GWT applications. I have adopted it and replaced JSNI with Elemental2 and WebStorage:

https://github.com/FrankHossfeld/InterAppEventBus

Hope that helps.

Upvotes: 1

Andrei
Andrei

Reputation: 1635

Here's how I've done it in the past:

  • First of all, in the module you want to export, you need to make sure that the code you're going to export doesn't end up obfuscated. This can be accomplished with the liberal use of @JsType; this is the new way of exporting JS, available in GWT 2.8 (as opposed to JSNI).
  • Your module's entry point onModuleLoad can be empty; it doesn't need to do anything.
  • Include your JS in the HTML you want to use (maybe the same page as your "main" module)
  • Check JSInterop documentation (perhaps the one available here) on how you can use native JS in your GWT app (because now, your GWT module became native JS). Import the classes via JSInterop from your library, and use them.

Please be aware of the async nature of the GWT JS loading; your library will be loading in an async manner, just like any JS application (and therefore, it won't be available immediately when your page loads). To overcome this, I've placed a call to a native JS function in my library's onModuleLoad function (i.e. to make sure you notify any potential listeners that the code has loaded; because when onModuleLoad runs, the code surely loaded).

Upvotes: 1

vsbehere
vsbehere

Reputation: 666

You can achieve this through separate Html file for each module.

So first of all create separate html for each application e.g. PrintPermit.html and specify corresponding nocache.js in each html.

then on your buttons in menu, add click handlers and in each on click load a corresponding html through Window.open()

e.g. for PrintPermit,

printPermitButton.addClickHandler(new ClickHandler{
        @Override
        public void onClick(ClickEvent arg0) {
              String s = GWT.getHostPageBaseURL() + "PrintPermit.html";
                Window.open(s, "PrintPermit", "");
        }
});

Please note the window.open will open in new tab in browser, you can also use gwt iframe to open html in same browser page.

Each module will have corresponding nocache.js and will be loaded through html using Window.open()

Upvotes: 0

Related Questions