getOrCreateJsObj() needs to return a class or interface annotated with
@JsType(isNative = true). That class or interface should have a method
addListener(String, fn) so you can call it in Java directly.
Corbett Tek schrieb am Donnerstag, 22. August 2024 um 15:57:31 UTC+2:
> When transporting some of my previously jsni written code to jsinterop
> framework, I am facing problems when accessing java methods from
> javascript file.
>
> For example in this jsni code I am accessing java
> method getOrCreateJsObj() and I need to convert this jsni code to jsinterop
> framework. How can I do this? What is the syntax for this? I tried official
> docs way, but it didn't worked out. Please help...
>
> //the jsni method that I need to convert into jsinterop
> private native void addWidgetListener(String event, JavaScriptObject fn)
> /*-{
> var component =
> [email protected]::getOrCreateJsObj()();
> component.addListener(event, fn);
> }-*/;
>
> public JavaScriptObject getOrCreateJsObj() {
> JavaScriptObject jsObj = getComponentJS(id);
> if (jsObj != null) {
> return jsObj;
> } else {
> return create(config);
> }
> }
>
--
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/97e49b05-6bf2-46e2-b7ff-c63b3637b321n%40googlegroups.com.