jsni

Java Hashmap and Mutlidimensional array type sig in JNSI?

I've got a method JSNI that calls a Java method that take a Hasmap as input. I've tried [email protected]::myMethod(Ljava/util/Hashmap;)(myHashMap); [email protected]::myMethod(Ljava/util/Hashmap<Ljava/lang/String,Ljava/lang/String>;)(myHashMap); I'm can't seem to define the correct type signature to include the Strings or...

Passing variable name into GWT's JSNI

Using the JavaScript Native Interface of GWT I can perform the following: public native static String getNativeVariableFoo() /*-{ return $wnd.foo; }-*/; Which will return the contents of a JavaScript variable called foo. How can I expand upon this to accept the variable name as a parameter? ie: public native static String getNat...

How can I pass an anonymous JavaScript object from Java to JavaScript in GWT?

Hi, I'm creating a GWT wrapper round a JavaScript library. One of the JavaScript functions takes an anonymous object as its argument e.g.: obj.buildTabs({ hide: true, placeholder: 'placeholder' }); On the Java side how do I create this type of JavaScript object and pass it to my native implementation? At the moment, on the Java sid...

Calling Java methods in a GWT module via Javacript of a Google Gears worker in a workerpool

I would like to know if it would be possible to call Java method of a GWT module within a worker in a Google Gears workerpool. For example given the class and method of a GWT module. package com.mycomp; public class MyClass implements EntryPoint, WorkerPoolMessageHandler { public void mymethod() { ... }} I have tried defining the fo...

jquery ready not waiting for plugins to finish loading

The following gwt jsni method code only "works" when I have firebug open, I presume because its slowing down the page rendering long enough for the external js files to finish loading. What am I doing wrong that its not waiting for the jquery plugin to finish loading before attempting to execute? private native void makeHtml(Element ...

Making a simple overlay class?

Hi, I'd like to make some really simple overlay classes in GWT to wrap some SVG stuff. I'd basically like to get a rectangle drawn, this is how I do it in javascript: var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); svg.setAttribute('width', '100%'); svg.setAttribute('height', '100%'); document.body.appendChild(...

GWT: forward user to a URL

Really simple question: From within GWT I want to forward the user away from my GWT page to a certain URL. What is the best way to do this? ...

GWT: Best practice for unit testing / mocking JSNI methods?

I have a class which uses JSNI to retrieve JSON data stored in the host page: protected native JsArray<JsonModel> getModels() /*-{ return $wnd.jsonData; }-*/; This method is called, and the data is then translated and process in a different method. How should I unit test this class, since I'm not able to instantiate (or seemingly ...

Javascript instanceof & typeof in GWT (JSNI)

Hi, I've encountered an curious problem while trying to use some objects through JSNI in GWT. Let's say we have javscript file with the function defined: test.js: function test(arg){ var type = typeof(arg); if (arg instanceof Array) alert('Array'); if (arg instanceof Object) alert('Object'); if (arg instanceof String) ...

In GWT how to know all the styles applied to a given element (by id or class name)

I have the following problem : in my GWT project there is a "main" css file for the application, inline css in the DOM that come from the application computation and a css file that is bundled in an archive uploaded to the application and dynamically loaded. Now I need for an Element to find which CSS rules are applied, coming from eith...

GWT : print button

Hi, I am trying to create a button that prints the current browser window. This is my current code, that uses (or at least it tries to use) JSNI: private Button print = new Button(constants.print(), new ClickHandler() { @Override public void onClick(final ClickEvent event) { /*-{ if ($wnd.print) { ...

Scrolling to the top of a page in a gwt application

I've got a gwt application and I want to scroll to the top of a page using this method: public static native void scrollTop() /*-{ $wnd.scroll(0, 0); }-*/; The method is called in the onClick-method of a TreeNodeListenerAdapter: new TreeNodeListenerAdapter() { @Override public void onClick(Node node, EventObject e) { scroll...

Does GWT JSNI support callbacks?

I am building a GWT app that uses Web SQL Local Storage ( http://dev.w3.org/html5/webdatabase/ ). The problem is that the Web SQL API uses callback functions as arguments. Is it possible to pass "Java" callbacks to JSNI? ...

problem related JSNI

pls use this http://code.google.com/p/google-web-toolkit-doc-1-6/wiki/DevGuideJavaFromJavaScript IFI means int float int but if i want to use String then how can i write? pls help ...