@Retention(value=CLASS) @Target(value={METHOD,CONSTRUCTOR}) public @interface JavaScriptBody
Visit an on-line demo
to play with JavaScriptBody annotation for real.
| Modifier and Type | Required Element and Description |
|---|---|
String[] |
args
Names of parameters for the method generated method that can
be referenced from
body(). |
String |
body
The actual body of the method in JavaScript.
|
| Modifier and Type | Optional Element and Description |
|---|---|
boolean |
javacall
Should a special syntax for calling back into Java object be turned on?
The syntax begins with
@ followed by fully qualified
package name of the class. |
boolean |
wait4js
Should we wait before the JavaScript snippet execution finishes?
Or not.
|
public abstract String[] args
body().public abstract String body
this.args() and possibly
thispublic abstract boolean javacall
@ followed by fully qualified
package name of the class. Now followed by :: and a method in
the class followed by its parameters enclosed inside (...).
This is the syntax one can use to call run()
method of Runnable:
r.@java.lang.Runnable::run()(). One can also call static methods. Just use:
var ten = @java.lang.Integer::parseInt(Ljava/lang/String;)("10")public abstract boolean wait4js
Some implementations that recognize the JavaScriptBody annotation
need to reschedule the JavaScript execution into different thread and
then it is easier for them to perform the execution asynchronously
and not wait for the result of the execution. This may however be
unexpected (for example when one awaits a callback into Java)
and as such it has to be explicitly allowed by specifying
wait4js = false. Such methods need to return void.
Implementations that execute the JavaScript synchronously may ignore this attribute.
Implementations that delay execution of JavaScript need to guarantee the order of snippets. Those that were submitted sooner, need to be executed sooner. Each snippet need to be executed in a timely manner (e.g. by a second, or so) even if there are no other calls made in the main program.
false in case one allows asynchronous execution
of the JavaScript snippetCopyright © 2014 NetBeans. All Rights Reserved.