Javascript to Java bridge functions.
Examples
var bean = __.newBean('com.enonic.xp.MyJavaUtils');
return __.toNativeObject(bean.findArray(arrayName));
Methods
(static) disposer(func)
Add a disposer that is called when the app is stopped.
Parameters:
Name | Type | Description |
---|---|---|
func |
Function to call. |
(static) newBean(name)
Creates a new JavaScript bean that wraps the given Java class and makes it's methods available to be called from JavaScript.
Parameters:
Name | Type | Description |
---|---|---|
name |
Classname for bean to create. |
(static) nullOrValue(value)
Converts a JavaScript variable that is undefined to a Java null
object.
If the JavaScript variable is defined, it is returned as is.
Parameters:
Name | Type | Description |
---|---|---|
value |
Value to convert. |
(static) registerMock(name, value)
Doc registerMock.
Parameters:
Name | Type | Description |
---|---|---|
name |
Name of mock. |
|
value |
Value to register. |
(static) toNativeObject(value)
Converts arrays or complex Java objects to JSon.
Parameters:
Name | Type | Description |
---|---|---|
value |
Value to convert. |
(static) toScriptValue(value)
Converts JSon to a Java Map structure that can be used as parameters to a Java method on a bean created with newBean
.
Parameters:
Name | Type | Description |
---|---|---|
value |
Value to convert. |