|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.vaadin.server.AbstractClientConnector
com.vaadin.server.AbstractExtension
com.vaadin.server.AbstractJavaScriptExtension
public abstract class AbstractJavaScriptExtension
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:
getConnectorId()
- returns a string with the id of the
connector.getParentId([connectorId])
- returns a string with the id of
the connector's parent. If connectorId
is provided, the id of
the parent of the corresponding connector with the passed id is returned
instead.getElement([connectorId])
- returns the DOM Element that is
the root of a connector's widget. null
is returned if the
connector can not be found or if the connector doesn't have a widget. If
connectorId
is not provided, the connector id of the current
connector will be used.getState()
- returns an object corresponding to the shared
state defined on the server. The scheme for conversion between Java and
JavaScript types is described bellow.registerRpc([name, ] rpcObject)
- registers the
rpcObject
as a RPC handler. rpcObject
should be an
object with field containing functions for all eligible RPC functions. If
name
is provided, the RPC handler will only used for RPC calls
for the RPC interface with the same fully qualified Java name. If no
name
is provided, the RPC handler will be used for all incoming
RPC invocations where the RPC method name is defined as a function field in
the handler. The scheme for conversion between Java types in the RPC
interface definition and the JavaScript values passed as arguments to the
handler functions is described bellow.getRpcProxy([name])
- returns an RPC proxy object. If
name
is provided, the proxy object will contain functions for
all methods in the RPC interface with the same fully qualified name, provided
a RPC handler has been registered by the server-side code. If no
name
is provided, the returned RPC proxy object will contain
functions for all methods in all RPC interfaces registered for the connector
on the server. If the same method name is present in multiple registered RPC
interfaces, the corresponding function in the RPC proxy object will throw an
exception when called. The scheme for conversion between Java types in the
RPC interface and the JavaScript values that should be passed to the
functions is described bellow.translateVaadinUri(uri)
- Translates a Vaadin URI to a URL
that can be used in the browser. This is just way of accessing
com.vaadin.client.ApplicationConnection#translateVaadinUri(String)
onStateChange
- If the JavaScript code assigns a function to
the field, that function is called whenever the contents of the shared state
is changed.addFunction(String, JavaScriptFunction)
on the server will
automatically be present as a function that triggers the registered function
on the server.callFunction(String, Object...)
on the server will be called if a function has been assigned to the field.Values in the Shared State and in RPC calls are converted between Java and JavaScript using the following conventions:
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface com.vaadin.server.ClientConnector |
---|
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener |
Constructor Summary | |
---|---|
AbstractJavaScriptExtension()
|
Method Summary | ||
---|---|---|
protected void |
addFunction(java.lang.String functionName,
JavaScriptFunction function)
Register a JavaScriptFunction that can be called from the
JavaScript using the provided name. |
|
protected void |
callFunction(java.lang.String name,
java.lang.Object... arguments)
Invoke a named function that the connector JavaScript has added to the JavaScript connector wrapper object. |
|
protected com.vaadin.shared.JavaScriptExtensionState |
getState()
Returns the shared state for this connector. |
|
protected
|
registerRpc(T implementation,
java.lang.Class<T> rpcInterfaceType)
Registers an RPC interface implementation for this component. |
Methods inherited from class com.vaadin.server.AbstractExtension |
---|
extend, getSupportedParentType, remove, setParent |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.vaadin.server.ClientConnector |
---|
addAttachListener, addDetachListener, attach, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getParent, getRpcManager, getStateType, getUI, handleConnectorRequest, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler |
Methods inherited from interface com.vaadin.shared.Connector |
---|
getConnectorId |
Constructor Detail |
---|
public AbstractJavaScriptExtension()
Method Detail |
---|
protected <T extends com.vaadin.shared.communication.ServerRpc> void registerRpc(T implementation, java.lang.Class<T> rpcInterfaceType)
AbstractClientConnector
registerRpc
in class AbstractClientConnector
implementation
- RPC interface implementationrpcInterfaceType
- RPC interface class for which the implementation should be
registeredprotected void addFunction(java.lang.String functionName, JavaScriptFunction function)
JavaScriptFunction
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 JavaScriptFunction
to be
invoked with the same arguments.
functionName
- the name that should be used for client-side callbackfunction
- the JavaScriptFunction
object that will be invoked
when the JavaScript function is calledprotected void callFunction(java.lang.String name, java.lang.Object... arguments)
name
- the name of the functionarguments
- function argumentsprotected com.vaadin.shared.JavaScriptExtensionState 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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |