public class JavaScript extends AbstractExtension
Modifier and Type | Class and Description |
---|---|
static interface |
JavaScript.JavaScriptCallbackRpc |
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
Constructor and Description |
---|
JavaScript()
Creates a new JavaScript object.
|
Modifier and Type | Method and Description |
---|---|
void |
addFunction(String name,
JavaScriptFunction function)
Add a new function to the global JavaScript namespace (i.e.
|
static void |
eval(String script)
Executes the given JavaScript code in the browser.
|
void |
execute(String script)
Executes the given JavaScript code in the browser.
|
static JavaScript |
getCurrent()
Get the JavaScript object for the current Page, or null if there is no
current page.
|
protected JavaScriptManagerState |
getState()
Returns the shared state for this connector.
|
protected JavaScriptManagerState |
getState(boolean markAsDirty)
Returns the shared state for this connector.
|
void |
remove()
JavaScript is not designed to be removed.
|
void |
removeFunction(String name)
Removes a JavaScriptFunction from the browser's global JavaScript
namespace.
|
extend, getParent, getSupportedParentType, setParent
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addMethodInvocationToQueue, attach, beforeClientResponse, createState, detach, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isConnectorEnabled, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource, updateDiffstate
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
addAttachListener, addDetachListener, attach, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, getUI, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
getConnectorId
public JavaScript()
protected JavaScriptManagerState getState()
AbstractClientConnector
As a side effect, marks the connector dirty so any changes done to the
state will be sent to the client. Use getState(false)
to avoid
marking the connector as dirty.
getState
in class AbstractClientConnector
protected JavaScriptManagerState getState(boolean markAsDirty)
AbstractClientConnector
getState
in class AbstractClientConnector
markAsDirty
- true if the connector should automatically be marked dirty,
false otherwiseAbstractClientConnector.getState()
public void addFunction(String name, JavaScriptFunction function)
call
method in the passed
JavaScriptFunction
object will be invoked with the same
parameters whenever the JavaScript function is called in the browser.
A function added with the name "myFunction"
can thus be
invoked with the following JavaScript code:
window.myFunction(argument1, argument2)
.
If the name parameter contains dots, simple objects are created on demand
to allow calling the function using the same name (e.g.
window.myObject.myFunction
).name
- the name that the function should get in the global JavaScript
namespace.function
- the JavaScriptFunction that will be invoked if the JavaScript
function is called.public void removeFunction(String name)
addFunction(String, JavaScriptFunction)
, these objects will not
be removed by this method.name
- the name of the callback to removepublic void execute(String script)
script
- The JavaScript code to run.public static void eval(String script)
script
- The JavaScript code to run.public static JavaScript getCurrent()
null
if there is no current page.Page.getCurrent()
public void remove()
remove
in interface Extension
remove
in class AbstractExtension
UnsupportedOperationException
- when invokedCopyright © 2018 Vaadin Ltd. All rights reserved.