jsni

JSNI dynamic function reference in GWT

萝らか妹 提交于 2019-12-01 08:04:38
问题 I would like to call arbitrary js function from gwt. Function name would be inside functionname variable. Something like this: private static native String execute(String functionName, JavaScriptObject data) /*-{ return $wnd.functionName(data); }-*/; I assume that something like this could be possible, but how to create fn variable to represent my arbitrary functionname function. private static native String execute(JavaScriptObject fn, JavaScriptObject data) /*-{ return fn(data); }-*/; 回答1:

Finding out when a GWT module has loaded

早过忘川 提交于 2019-11-30 09:58:39
I am exporting a GWT method to native javascript in the following manner: public class FaceBookGalleryEntryPoint implements EntryPoint { @Override public void onModuleLoad() { FacebookGallery facebookGallery = new FacebookGallery(); RootPanel.get().add(facebookGallery); initLoadGallery(facebookGallery); } private native void initLoadGallery(FacebookGallery pl) /*-{ $wnd.loadGallery = function (galleryId) { pl.@com.example.fbg.client.FacebookGallery::loadGallery(Ljava/lang/String;)(galleryId); }; }-*/; } In the host page, I am trying to invoke it: <html> <head> <title>Facebook image gallery<

Something other than an int was returned from JSNI method

风格不统一 提交于 2019-11-30 06:45:28
I am running a GWT application in hosted mode. Sporadically I get a strange HostedModeException complaining about the type of the JS value returned from JSNI. Sometimes it is during deserialization: com.google.gwt.dev.shell.HostedModeException: Something other than an int was returned from JSNI method '@com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader::readInt()': JS value of type boolean, expected int at com.google.gwt.dev.shell.JsValueGlue.getIntRange(JsValueGlue.java:266) at com.google.gwt.dev.shell.JsValueGlue.get(JsValueGlue.java:144) at com.google.gwt.dev.shell

Use jquery inside GWT jsni

半城伤御伤魂 提交于 2019-11-30 03:54:40
I am not able to use $("#"+profileId).offset().top from inside my gwt jsni function. I tried this $wnd.$("#"+profileId).offset().top but this is also not working. I feel i am missing syntax here. Could anybody help Three solutions for this question: 1- Your Jsni code looks fine except that you have to enclose it in the corresponding native function and return a double (or any other number type if you want gwt to make the casting). native double getTop(String profileId) /*-{ return $wnd.$("#" + profileId).offset().top; }-*/; If you wanted to see errors through your UncaughExceptionHandler you

Finding out when a GWT module has loaded

Deadly 提交于 2019-11-29 15:09:11
问题 I am exporting a GWT method to native javascript in the following manner: public class FaceBookGalleryEntryPoint implements EntryPoint { @Override public void onModuleLoad() { FacebookGallery facebookGallery = new FacebookGallery(); RootPanel.get().add(facebookGallery); initLoadGallery(facebookGallery); } private native void initLoadGallery(FacebookGallery pl) /*-{ $wnd.loadGallery = function (galleryId) { pl.@com.example.fbg.client.FacebookGallery::loadGallery(Ljava/lang/String;)(galleryId);

How to run JavaScript function from GWT Java with JSNI? [duplicate]

半世苍凉 提交于 2019-11-29 13:58:58
This question already has an answer here: How to call GWT java function from Javascript? 1 answer Can't understand from the manual: how actually to run JS function from Java? For example, I have a function in my html page: <script type="text/javascript" language="javascript"> function foo() { alert('Foo!'); } </script> The following module shows two buttons, only second of which works: public class Test_GoogleWeb_JSNI_01 implements EntryPoint { public void onModuleLoad() { Button fooButton = new Button("Foo!"); fooButton.addClickHandler(new ClickHandler(){ public void onClick(ClickEvent event)

Something other than an int was returned from JSNI method

戏子无情 提交于 2019-11-29 06:10:42
问题 I am running a GWT application in hosted mode. Sporadically I get a strange HostedModeException complaining about the type of the JS value returned from JSNI. Sometimes it is during deserialization: com.google.gwt.dev.shell.HostedModeException: Something other than an int was returned from JSNI method '@com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader::readInt()': JS value of type boolean, expected int at com.google.gwt.dev.shell.JsValueGlue.getIntRange(JsValueGlue.java:266

GWT JSNI - problem passing Strings

心已入冬 提交于 2019-11-28 10:22:53
I'm trying to provide some function hooks in my GWT project: private TextBox hello = new TextBox(); private void helloMethod(String from) { hello.setText(from); } private native void publish() /*-{ $wnd.setText = $entry(this.@com.example.my.Class::helloMethod(Ljava/lang/String;)); }-*/; publish() being called in onModuleLoad() . But this doesn't work, providing no feedback as to why in the dev console. I've also tried: private native void publish() /*-{ $wnd.setText = function(from) { alert(from); this.@com.example.my.Class::helloMethod(Ljava/lang/String;)(from); } }-*/; which will toss a java

How to call GWT java function from Javascript?

耗尽温柔 提交于 2019-11-28 10:05:56
Is it possible to call Java (GWT) methods from Javascript? It is also unclear from documentation. All samples here http://code.google.com/intl/ru/webtoolkit/doc/latest/DevGuideCodingBasicsJSNI.html demonstrate calling java functions from JSNI (not JS) functions. UPDATE 1 Here is a Java code: public class Test_GoogleWeb_JSNI_02 implements EntryPoint { /** * This is the entry point method. */ public void onModuleLoad() { } public static void Callee() { Window.alert("Callee"); } } Here is caller button samples in html: <input type='button' value='Call' onclick='Test02()'> And here are some

How to run JavaScript function from GWT Java with JSNI? [duplicate]

家住魔仙堡 提交于 2019-11-28 07:25:42
问题 This question already has an answer here: How to call GWT java function from Javascript? 1 answer Can't understand from the manual: how actually to run JS function from Java? For example, I have a function in my html page: <script type="text/javascript" language="javascript"> function foo() { alert('Foo!'); } </script> The following module shows two buttons, only second of which works: public class Test_GoogleWeb_JSNI_01 implements EntryPoint { public void onModuleLoad() { Button fooButton =