0

I know how to call Javascript from GWT.But I have a javascript function that returns a string so, how could I when that function is called send it to GWT.

Hope this makes sense

1 Answer 1

2

This is how you collect strings from JSNI fn

public static native String stringExample() /*-{ return "String1"; }-*/;

This is how you pass a string to JSNI fn

public static native void alert(String msg) /*-{ $wnd.alert(msg); }-*/;

Hope this is what you were looking for.

Sign up to request clarification or add additional context in comments.

2 Comments

I need to know when I call a javascript function, how to pass it to the java code in gwt.Like if I had a function that returned a string in javascript when i called that function it would send it to the java code to say update a textBox. Hope that makes sense.
@james You just use the functions as Java functions now. The js code has been wrapped in a java function. so in gwt use String gwtString=Class.stringExample(); Class.alert(gwtString);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.