-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is something like GWT JSNI supported? #138
Comments
If your JS code that you want to use is quite big, you'll only need to But if you only want to code some small JS code directly you can do it with On Nov 16, 2016 11:57 PM, "WhiteTrashLord" notifications@github.com wrote:
|
Thank you for your answer. I would use it only for short JS code. But I would also be able to define my own parameters. This is no supported by $js, or? In TeaVM it can be done by something like this: @JSBody(params = "message", script = "alert(message);") This is much better than GWT JSNI in my opinion. It would be great if you can implement something like this :) |
if you want with this construction to bridge the global alert method this is already done in https://github.com/st-js/html-bridge/blob/master/src/main/java/org/stjs/javascript/Global.java#L33 But if you have somewhere a global function called: it's enough to create a class
no other annotations are needed. Was this your intention? |
Thank you for your answer. It seems that this exactly what I was looking for :) Is it also possible to give a method in Java a global scope? So for example I would like to invoke such a method in the Javascript code only with "helloWorld()".
|
You have the annotation @globalscope on a class, that will make that all
the static methods of that class will be added to the global JS scope (so
that you can call those functions in JS as you suggested)
…On Wed, Apr 5, 2017 at 9:55 PM, WhiteTrashLord ***@***.***> wrote:
Thank you for your answer. It seems that this exactly what I was looking
for :)
Is it also possible to give a method in Java a global scope?
So for example I would like to invoke such a method in the Javascript code
only with "helloWorld()".
public static void helloWorld()
{
alert("Hello world");
}
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#138 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABgADaS2mqU71Rske1toiwR6KY9iqTvzks5rs_GYgaJpZM4K0lcL>
.
|
I want to write my own native Javascript code in my Java code. In GWT I can do it with JSNI.
STJS also supports it? I read the documentation and could not find anything like it.
The text was updated successfully, but these errors were encountered: