com.vaadin.ui
Class AbstractJavaScriptComponent

java.lang.Object
  extended by com.vaadin.terminal.AbstractClientConnector
      extended by com.vaadin.ui.AbstractComponent
          extended by com.vaadin.ui.AbstractJavaScriptComponent
All Implemented Interfaces:
MethodEventSource, Connector, ClientConnector, RpcTarget, Sizeable, Component, Serializable

public abstract class AbstractJavaScriptComponent
extends AbstractComponent

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

When a new JavaScript component is initialized in the browser, the framework will look for a globally defined JavaScript function that will initialize the component. 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_MyComponent for the server-side com.example.MyComponent extends AbstractJavaScriptComponent class. If MyComponent instead extends com.example.SuperComponent , then com_example_SuperComponent will also be attempted if com_example_MyComponent has not been defined.

JavaScript components have a very simple GWT widget (JavaScriptWidget ) just consisting of a div element to which the JavaScript code should initialize its own user interface.

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

Nested Class Summary
 
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractComponent
AbstractComponent.ComponentErrorEvent, AbstractComponent.ComponentErrorHandler
 
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
Component.ErrorEvent, Component.ErrorListener, Component.Event, Component.Focusable, Component.Listener
 
Nested classes/interfaces inherited from interface com.vaadin.terminal.Sizeable
Sizeable.Unit
 
Field Summary
 
Fields inherited from interface com.vaadin.terminal.Sizeable
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
 
Constructor Summary
AbstractJavaScriptComponent()
           
 
Method Summary
 JavaScriptComponentState getState()
          Returns the shared state bean with information to be sent from the server to the client.
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.ui.AbstractComponent
addListener, addListener, addListener, addListener, addShortcutListener, addStyleName, attach, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, fireEvent, focus, getActionManager, getApplication, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorHandler, getErrorMessage, getHeight, getHeightUnits, getIcon, getListeners, getLocale, getParent, getRoot, getStyle, getStyleName, getWidth, getWidthUnits, handleError, hasListeners, isConnectorEnabled, isEnabled, isImmediate, isReadOnly, isVisible, removeListener, removeListener, removeListener, removeListener, removeListener, removeShortcutListener, removeStyleName, requestRepaint, setCaption, setComponentError, setData, setDebugId, setDescription, setEnabled, setErrorHandler, setHeight, setHeight, setIcon, setImmediate, setLocale, setParent, setReadOnly, setSizeFull, setSizeUndefined, setStyle, setStyleName, setVisible, setWidth, setWidth, updateState
 
Methods inherited from class com.vaadin.terminal.AbstractClientConnector
addExtension, addMethodInvocationToQueue, createState, getAllChildrenIterable, getConnectorId, getExtensions, getRpcManager, getRpcProxy, getStateType, registerRpc, removeExtension, 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
getExtensions, getStateType, removeExtension, 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

AbstractJavaScriptComponent

public AbstractJavaScriptComponent()
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 JavaScriptComponentState getState()
Description copied from class: AbstractComponent
Returns the shared state bean with information to be sent from the server to the client. Subclasses should override this method and set any relevant fields of the state returned by super.getState().

Specified by:
getState in interface Connector
Specified by:
getState in interface Component
Overrides:
getState in class AbstractComponent
Returns:
updated component shared state


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