public abstract class Fn extends Object
Fn.Presenter.defineFn(java.lang.String, java.lang.String...).| Modifier and Type | Class and Description |
|---|---|
static interface |
Fn.FromJavaScript
Additional interface to be implemented by
Fn.Presenters that
need to convert JavaScript object (usually array) to Java object
when calling back from JavaScript to Java. |
static interface |
Fn.Presenter
The representation of a presenter - usually a browser window.
|
static interface |
Fn.ToJavaScript
Additional interface to be implemented by
Fn.Presenters that
wish to control what objects are passed into the JavaScript virtual
machine. |
| Modifier | Constructor and Description |
|---|---|
protected |
Fn()
Deprecated.
Ineffective as of 0.6.
Provide a presenter via
Fn(org.apidesign.html.boot.spi.Fn.Presenter)
constructor |
protected |
Fn(Fn.Presenter presenter)
Creates new function object and associates it with given presenter.
|
| Modifier and Type | Method and Description |
|---|---|
static Closeable |
activate(Fn.Presenter p)
Activates given presenter.
|
static Fn.Presenter |
activePresenter()
The currently active presenter.
|
static Fn |
define(Class<?> caller,
String code,
String... names)
Helper method to find current presenter and ask it to define new
function by calling
Fn.Presenter.defineFn(java.lang.String, java.lang.String...). |
abstract Object |
invoke(Object thiz,
Object... args)
Invokes the defined function with specified
this and
appropriate arguments. |
boolean |
isValid()
True, if currently active presenter is the same as presenter this
function has been created for via
Fn(org.apidesign.html.boot.spi.Fn.Presenter). |
static boolean |
isValid(Fn fnOrNull)
Helper method to check if the provided instance is valid function.
|
static Fn |
preload(Fn fn,
Class<?> caller,
String resource)
Wraps function to ensure that the script represented by
resource
gets loaded into the browser environment before the function fn
is executed. |
protected Fn.Presenter |
presenter()
Provides the function implementation access to the presenter provided
in {@link #Fn(org.apidesign.html.boot.spi.Fn.Presenter) the constructor).
|
@Deprecated protected Fn()
Fn(org.apidesign.html.boot.spi.Fn.Presenter)
constructorprotected Fn(Fn.Presenter presenter)
presenter - the browser presenter associated with this functionpublic final boolean isValid()
Fn(org.apidesign.html.boot.spi.Fn.Presenter).public static boolean isValid(Fn fnOrNull)
isValid()
check.fnOrNull - function or nullpublic static Fn define(Class<?> caller, String code, String... names)
Fn.Presenter.defineFn(java.lang.String, java.lang.String...).caller - the class who wishes to define the functioncode - the body of the function (can reference this and names variables)names - names of individual parametersinvoked
- can return null if there is no presenterpublic static Fn preload(Fn fn, Class<?> caller, String resource)
resource
gets loaded into the browser environment before the function fn
is executed.fn - original function to callcaller - the class who wishes to define/call the functionresource - resources (accessible via ClassLoader.getResource(java.lang.String))
with a JavaScript that is supposed to loaded into the browser
environmentfnpublic static Fn.Presenter activePresenter()
nullpublic static Closeable activate(Fn.Presenter p)
JavaScriptBody annotation:
try (Closeable c = Fn.activate(presenter)) {
doCallsInPresenterContext();
}
p - the presenter that should be active until closable is closedpublic abstract Object invoke(Object thiz, Object... args) throws Exception
this and
appropriate arguments.thiz - the meaning of this inside of the JavaScript
function - can be nullargs - arguments for the functionException - if something goes wrong, as exception may be thrownprotected final Fn.Presenter presenter()
null)Copyright © 2014 NetBeans. All Rights Reserved.