I've been trying to pass a value into a Javascript method through JSNI but it keeps on failing.
Is this method valid:
public static native JavaScriptObject getProductById(long pid) /*-{
var productId = pid;
var product = $wnd.products({id:productId}).first();
return product;
}-*/;
I can say that the JS method is correct, since if I put a constant value in place of productId
, I get the correct output.
What am I missing?