private native void init()/*-{
function OnMouseMove(e) {
//following code doesn't work
this.@p::javaMethod(Ljava/lang/Integer;Ljava/lang/Integer;)(intVal,_intVal);
}
}
}
----------------------------------------------------------------------------------------------------------
As described above,how to solve this problem?
Say you have this code in your normal GWT/Java code, in a class
"FunConfigurator" :
public void onJCrop(int x, int y, int x2, int y2)
{
Window.alert("in gwt: (" + x + "," + y + ")");
}
Now to call this from JSNI do the following (only the fc.@ line is of
any importance) :
private static native void activateJCrop(FunConfigurator fc)
/*-{
$wnd.jQuery(function()
{
$wnd.jQuery('#cropbox').Jcrop({
onSelect: showCoords
});
});
function showCoords(c)
{
// variables can be accessed here as
// c.x, c.y, c.x2, c.y2, c.w, c.h
var s = "hallo"
fc.@be.fks.elka.clientgui.client.configurator.fun.FunConfigurator::onJCrop(IIII)
(c.x, c.y, c.x2, c.y2);
};
}-*/;
In detail :
fc.@be.fks.elka.clientgui.client.configurator.fun.FunConfigurator::onJCrop(IIII)
(c.x, c.y, c.x2, c.y2);
fc = The class that contains the java method you want to call. This is
passed as a parameter to the JSNI method
@be.fks.elka.clientgui.client.configurator.fun.FunConfigurator = The
fully qualified classname (packagename + funconfigurator)
onJCrop : The name of the Java method to call
(IIII) : The params are 4 integers (see below for other available
types)
((c.x, c.y, c.x2, c.y2) : The actual parameters to pas from JS to Java
Note that the IIII means : 4 integers.
These are the possible types :
Z boolean
B byte
C char
S short
I int
J long
F float
D double
L fully-qualified-class ; fully-qualified-class
[ type type[]
( arg-types ) ret-type method type
Hope this helps...