com.vaadin.terminal
Class AbstractJavaScriptExtension

java.lang.Object
  extended by com.vaadin.terminal.AbstractClientConnector
      extended by com.vaadin.terminal.AbstractExtension
          extended by com.vaadin.terminal.AbstractJavaScriptExtension
All Implemented Interfaces:
Extension, Connector, ClientConnector, RpcTarget, Serializable

public abstract class AbstractJavaScriptExtension
extends AbstractExtension

Base class for Extensions with all client-side logic implemented using JavaScript.

When a new JavaScript extension is initialized in the browser, the framework will look for a globally defined JavaScript function that will initialize the extension. The name of the initialization function is formed by replacing . with _ in the name of the server-side class. If no such function is defined, each super class is used in turn until a match is found. The framework will thus first attempt with com_example_MyExtension for the server-side com.example.MyExtension extends AbstractJavaScriptExtension class. If MyExtension instead extends com.example.SuperExtension , then com_example_SuperExtension will also be attempted if com_example_MyExtension has not been defined.

The initialization function will be called with this pointing to a connector wrapper object providing integration to Vaadin with the following functions:

The connector wrapper also supports these special functions:

Values in the Shared State and in RPC calls are converted between Java and JavaScript using the following conventions:

Since:
7.0.0
Version:
7.0.0.alpha3
Author:
Vaadin Ltd
See Also:
Serialized Form

Constructor Summary
AbstractJavaScriptExtension()
           
 
Method Summary
 JavaScriptExtensionState getState()
          Gets the current shared state of the connector.
protected  void invokeCallback(String name, Object... arguments)
          Invoke a named function that the connector JavaScript has added to the JavaScript connector wrapper object.
protected  void registerCallback(String functionName, JavaScriptCallback javaScriptCallback)
          Register a JavaScriptCallback that can be called from the JavaScript using the provided name.
protected
<T> void
registerRpc(T implementation, Class<T> rpcInterfaceType)
          Registers an RPC interface implementation for this component.
 
Methods inherited from class com.vaadin.terminal.AbstractExtension
extend, getSupportedParentType, removeFromTarget, setParent
 
Methods inherited from class com.vaadin.terminal.AbstractClientConnector
addExtension, addMethodInvocationToQueue, attach, createState, detach, getAllChildrenIterable, getApplication, getConnectorId, getExtensions, getParent, getRoot, getRpcManager, getRpcProxy, getStateType, isConnectorEnabled, registerRpc, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.vaadin.terminal.gwt.server.ClientConnector
attach, detach, getExtensions, getParent, getRoot, getStateType, isConnectorEnabled, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls
 
Methods inherited from interface com.vaadin.terminal.gwt.client.Connector
getConnectorId
 
Methods inherited from interface com.vaadin.terminal.gwt.server.RpcTarget
getRpcManager
 

Constructor Detail

AbstractJavaScriptExtension

public AbstractJavaScriptExtension()
Method Detail

registerRpc

protected <T> void registerRpc(T implementation,
                               Class<T> rpcInterfaceType)
Description copied from class: AbstractClientConnector
Registers an RPC interface implementation for this component. A component can listen to multiple RPC interfaces, and subclasses can register additional implementations.

Overrides:
registerRpc in class AbstractClientConnector
Parameters:
implementation - RPC interface implementation
rpcInterfaceType - RPC interface class for which the implementation should be registered

registerCallback

protected void registerCallback(String functionName,
                                JavaScriptCallback javaScriptCallback)
Register a JavaScriptCallback that can be called from the JavaScript using the provided name. A JavaScript function with the provided name will be added to the connector wrapper object (initially available as this). Calling that JavaScript function will cause the call method in the registered JavaScriptCallback to be invoked with the same arguments.

Parameters:
functionName - the name that should be used for client-side callback
javaScriptCallback - the callback object that will be invoked when the JavaScript function is called

invokeCallback

protected void invokeCallback(String name,
                              Object... arguments)
Invoke a named function that the connector JavaScript has added to the JavaScript connector wrapper object. The arguments should only contain data types that can be represented in JavaScript including primitives, their boxed types, arrays, String, List, Set, Map, Connector and JavaBeans.

Parameters:
name - the name of the function
arguments - function arguments

getState

public JavaScriptExtensionState getState()
Description copied from interface: Connector
Gets the current shared state of the connector.

Specified by:
getState in interface Connector
Overrides:
getState in class AbstractClientConnector
Returns:
state The shared state object. Can be any sub type of SharedState. Never null.


Copyright © 2000-2011 Vaadin Ltd. All Rights Reserved.