OK, it's working now with: setTimeout
https://github.com/lofidewanto/gwt-widget-jsinterop/blob/main/src/main/java/com/github/lofi/public/testcalculator-withwait.js
Now you can see in the example how to call your Widget from JavaScript...
Just simple as creating that object and use as you wish...
var calculator = new Calculator("From JS withwait");
element.appendChild(calculator.getAsElement());
Cheers,
Lofi
[email protected] schrieb am Dienstag, 2. März 2021 um 20:18:10 UTC+1:
> I build a simple example:
> https://github.com/lofidewanto/gwt-widget-jsinterop
>
> I also found some answer in StackOverflow but it's all Java based (see the
> README above). What I understood is that the Widget should be called from a
> pure JS (VueJS or whatever JS).
>
> - Calculator.java
>
> <https://github.com/lofidewanto/gwt-widget-jsinterop/blob/main/src/main/java/com/github/lofi/client/Calculator.java>
>
> -- Composite Widget
> - JS uses the Calculator: testcalculator-nowait.js
>
> <https://github.com/lofidewanto/gwt-widget-jsinterop/blob/main/src/main/java/com/github/lofi/public/testcalculator-nowait.js>
>
> I use ScriptInjector to inject testcalculator-nowait.js
> <https://github.com/lofidewanto/gwt-widget-jsinterop/blob/main/src/main/java/com/github/lofi/public/testcalculator-nowait.js>
> .
>
> If I tried to use this JS testcalculator-withwait.js
> <https://github.com/lofidewanto/gwt-widget-jsinterop/blob/main/src/main/java/com/github/lofi/public/testcalculator-withwait.js>
> directly
> in index.html
> <https://github.com/lofidewanto/gwt-widget-jsinterop/blob/main/src/main/java/com/github/lofi/public/index.html>
>
> it seems that it cannot find the Calculator class. I have the feeling that
> the Calculator JsInterop hasn't been loaded but the
> testcalculator-withwait.js already running. Using ScriptInjector makes this
> possible (testcalculator-nowait.js) but I don't think, that this was the
> question.
>
> Maybe Thomas could check, I'm not sure how to "wait" in JS until the
> JsInterop class is loaded...
>
> Cheers,
> Lofi
> [email protected] schrieb am Dienstag, 2. März 2021 um 19:36:47 UTC+1:
>
>> I would:
>>
>> 1. create a new *.gwt.xml with a new EntryPoint that won't launch the
>> GWT app but instead expose a function (using JsInterop) to "run" your
>> module
>> 2. that function would use receive an element ID and use
>> RootPanel.get(id) to put the GWT UI inside (that's not the only way, but
>> definitely the easiest); ideally it would also return a function that you
>> would call from Vue at "unmount", but could instead return the RootPanel
>> so
>> it could be passed to another function exposed by the module's
>> onModuleLoad.
>> 3. the "unmount" callback would simply call
>> RootPanel.detachNow(rootPanel)
>>
>> That way, the Vue app could actually load the GWT module immediately, but
>> then only use it by calling its exposed function when it needs to display
>> the GWT module; and when it no longer needs it, it should properly "detach"
>> it.
>>
>> On Tuesday, March 2, 2021 at 5:09:24 AM UTC+1 [email protected] wrote:
>>
>>> For example:
>>> I have a vue app and classic gwt application, The gwt application have
>>> lot of module .
>>> but I only want to one module (eg: A query UI) integration to my vue
>>> app using js
>>> How can I done this?
>>> Tks.
>>>
>>>
>>>
--
You received this message because you are subscribed to the Google Groups "GWT
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-web-toolkit/59484957-dcc8-44e6-9d7d-f4c95b2dde5an%40googlegroups.com.