The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

LeLLuMe (1) [Avatar] Offline
i'm trying to write a wrapper fot the JavaScript library Flotr (

This is the code:

Definition of the GWT Implementation Class

public class ClassFlotrImpl {

public native ClassFlotr disegna(Element elemento)
var d1 = [[4, 6], [3, 9], [12, 5], [5, 34]];
var d2 = [[0, 3], [4, 8], [8, 5], [9, 13]];
var f = $wnd.Flotr.draw(elemento, [ d1, d2 ]);

return f

Definition of the GWT JavaScriptObjectClass

public class ClassFlotr extends JavaScriptObject {
private static ClassFlotrImpl grafico = new ClassFlotrImpl();

public static ClassFlotr disegna(Element elemento){


Definition of the GWT Widget Class

public class ClassFlotrWidget extends Composite {
VerticalPanel area = new VerticalPanel();
VerticalPanel areaGrafico = new VerticalPanel();
static ClassFlotr grafico = null;

public ClassFlotrWidget (){

public ClassFlotr disegna(Element elemento){
if (grafico == null){
grafico = grafico.disegna(elemento);
return grafico;


The calling code

ClassFlotrWidget flotrw = new ClassFlotrWidget();

The code seems to be right, but despite that, at runtime the follow error message appears:
[ERROR] No JavaScript body found for native method 'public native it.uniba.di.client.ClassFlotr disegna( elemento)' in type 'class it.uniba.di.client.ClassFlotrImpl'

Why? Can you help me?

Best regards.

adam.tacy (269) [Avatar] Offline
Re: No JavaScript body found for native method...

I'm taking a bit of a stab in the dark here, but I think there are two things wrong with your JSNI description in ClassFlotrImpl

1) You have /*-{ on a separate line from the method declaration - though shouldn't really be a problem
2) You have {-*/ at the end of your body as opposed to }-*/ - this is probably the issue, unless you've just made a type in the post and in the code it is correct.....

I would tweak both of those and see what it gets you.


Maerch (1) [Avatar] Offline
Re: No JavaScript body found for native method...

i tried the code with the two suggestions from adam.tracy. Now there is no failure instead of this it draws simply nothing with


Has the author of this thread solved the problem and if yes than how?

Or can anybody else explain me what the reason is?
The Flotr *.js files are included to GWT successfully and this library draws a chart with JS in a HTML site (see code-snippet). How can i wrap this in GWT?

I would be very thankful for every hint or suggestion or even a link to a site which could help me.

Regards Maerch

* Fill series d1 and d2.
var d1 = [];
for(var i = 0; i < 14; i += 0.5)
d1.push([i, Math.sin(i)]);

var d2 = [[0, 3], [4, 8], [8, 5], [9, 13]];

* Draw the graph.
Flotr.draw($('container'), [ d1, d2 ]);