com.vaadin.server
Interface ClientConnector

All Superinterfaces:
com.vaadin.shared.Connector, RpcTarget, java.io.Serializable
All Known Subinterfaces:
Component, Component.Focusable, ComponentContainer, DragSource, DropTarget, Extension, Field<T>, HasComponents, Layout, LegacyComponent
All Known Implementing Classes:
AbsoluteLayout, AbstractClientConnector, AbstractComponent, AbstractComponentContainer, AbstractEmbedded, AbstractExtension, AbstractField, AbstractJavaScriptComponent, AbstractJavaScriptExtension, AbstractLayout, AbstractMedia, AbstractOrderedLayout, AbstractSelect, AbstractSplitPanel, AbstractTextField, Accordion, Audio, BrowserFrame, Button, CheckBox, ComboBox, CssLayout, CustomComponent, CustomField, CustomLayout, DateField, DragAndDropService, DragAndDropWrapper, Embedded, Flash, Form, FormLayout, GridLayout, HorizontalLayout, HorizontalSplitPanel, Image, InlineDateField, JavaScript, Label, Link, ListSelect, LoginForm, MenuBar, NativeButton, NativeSelect, Navigator.EmptyView, Navigator.SimpleViewDisplay, OptionGroup, Panel, PasswordField, PopupDateField, PopupView, ProgressIndicator, RichTextArea, Select, Slider, Table, TabSheet, TextArea, TextField, Tree, TreeTable, TwinColSelect, UI, UI.LegacyWindow, Upload, VerticalLayout, VerticalSplitPanel, Video, Window

public interface ClientConnector
extends com.vaadin.shared.Connector, RpcTarget

Interface implemented by all connectors that are capable of communicating with the client side

Since:
7.0.0
Author:
Vaadin Ltd

Method Summary
 void attach()
          Notifies the connector that it is connected to an application.
 void beforeClientResponse(boolean initial)
          Called before the shared state and RPC invocations are sent to the client.
 void detach()
          Notifies the component that it is detached from the application.
 org.json.JSONObject encodeState()
          Called by the framework to encode the state to a JSONObject.
 java.util.Collection<Extension> getExtensions()
          Get a read-only collection of all extensions attached to this connector.
 ClientConnector getParent()
           
 java.lang.Class<? extends com.vaadin.shared.communication.SharedState> getStateType()
          Returns the type of the shared state for this connector
 UI getUI()
          Returns the UI this connector is attached to
 boolean handleConnectorRequest(VaadinRequest request, VaadinResponse response, java.lang.String path)
          Handle a request directed to this connector.
 boolean isConnectorEnabled()
          Checks if the communicator is enabled.
 void markAsDirty()
          Marks that this connector's state might have changed.
 void markAsDirtyRecursive()
          Causes this connector and all connectors below it to be marked as dirty.
 void removeExtension(Extension extension)
          Remove an extension from this connector.
 void requestRepaint()
          Deprecated. As of 7.0.0, use markAsDirty() instead
 void requestRepaintAll()
          Deprecated. As of 7.0.0, use markAsDirtyRecursive() instead
 java.util.List<ClientMethodInvocation> retrievePendingRpcCalls()
          Returns the list of pending server to client RPC calls and clears the list.
 void setParent(ClientConnector parent)
          Sets the parent connector of the connector.
 
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
 
Methods inherited from interface com.vaadin.server.RpcTarget
getRpcManager
 

Method Detail

retrievePendingRpcCalls

java.util.List<ClientMethodInvocation> retrievePendingRpcCalls()
Returns the list of pending server to client RPC calls and clears the list.

Returns:
an unmodifiable ordered list of pending server to client method calls (not null)

isConnectorEnabled

boolean isConnectorEnabled()
Checks if the communicator is enabled. An enabled communicator is allowed to receive messages from its counter-part.

Returns:
true if the connector can receive messages, false otherwise

getStateType

java.lang.Class<? extends com.vaadin.shared.communication.SharedState> getStateType()
Returns the type of the shared state for this connector

Returns:
The type of the state. Must never return null.

getParent

ClientConnector getParent()
Specified by:
getParent in interface com.vaadin.shared.Connector

requestRepaint

@Deprecated
void requestRepaint()
Deprecated. As of 7.0.0, use markAsDirty() instead


markAsDirty

void markAsDirty()
Marks that this connector's state might have changed. When the framework is about to send new data to the client-side, it will run beforeClientResponse(boolean) followed by encodeState() for all connectors that are marked as dirty and send any updated state info to the client.

Since:
7.0.0

requestRepaintAll

@Deprecated
void requestRepaintAll()
Deprecated. As of 7.0.0, use markAsDirtyRecursive() instead


markAsDirtyRecursive

void markAsDirtyRecursive()
Causes this connector and all connectors below it to be marked as dirty.

This should only be used in special cases, e.g when the state of a descendant depends on the state of an ancestor.

Since:
7.0.0
See Also:
markAsDirty()

setParent

void setParent(ClientConnector parent)
Sets the parent connector of the connector.

This method automatically calls attach() if the connector becomes attached to the application, regardless of whether it was attached previously. Conversely, if the parent is null and the connector is attached to the application, detach() is called for the connector.

This method is rarely called directly. One of the ComponentContainer.addComponent(Component) or AbstractClientConnector.addExtension(Extension) methods are normally used for adding connectors to a parent and they will call this method implicitly.

It is not possible to change the parent without first setting the parent to null.

Parameters:
parent - the parent connector
Throws:
java.lang.IllegalStateException - if a parent is given even though the connector already has a parent

attach

void attach()
Notifies the connector that it is connected to an application.

The caller of this method is setParent(ClientConnector) if the parent is itself already attached to the application. If not, the parent will call the attach() for all its children when it is attached to the application. This method is always called before the connector's data is sent to the client-side for the first time.

The attachment logic is implemented in AbstractClientConnector.


detach

void detach()
Notifies the component that it is detached from the application.

The caller of this method is setParent(ClientConnector) if the parent is in the application. When the parent is detached from the application it is its response to call detach() for all the children and to detach itself from the terminal.


getExtensions

java.util.Collection<Extension> getExtensions()
Get a read-only collection of all extensions attached to this connector.

Returns:
a collection of extensions

removeExtension

void removeExtension(Extension extension)
Remove an extension from this connector.

Parameters:
extension - the extension to remove.

getUI

UI getUI()
Returns the UI this connector is attached to

Returns:
The UI this connector is attached to or null if it is not attached to any UI

beforeClientResponse

void beforeClientResponse(boolean initial)
Called before the shared state and RPC invocations are sent to the client. Gives the connector an opportunity to set computed/dynamic state values or to invoke last minute RPC methods depending on other component features.

This method must not alter the component hierarchy in any way. Calling markAsDirty() from this method will have no effect.

Parameters:
initial - true if the client-side connector will be created and initialized after this method has been invoked. false if there is already an initialized client-side connector.
Since:
7.0

encodeState

org.json.JSONObject encodeState()
                                throws org.json.JSONException
Called by the framework to encode the state to a JSONObject. This is typically done by calling the static method AbstractCommunicationManager.encodeState(ClientConnector, SharedState) .

Returns:
a JSON object with the encoded connector state
Throws:
org.json.JSONException - if the state can not be encoded

handleConnectorRequest

boolean handleConnectorRequest(VaadinRequest request,
                               VaadinResponse response,
                               java.lang.String path)
                               throws java.io.IOException
Handle a request directed to this connector. This can be used by connectors to dynamically generate a response and it is also used internally when serving ConnectorResources.

Requests to /APP/connector/[ui id]/[connector id]/ are routed to this method with the remaining part of the requested path available in the path parameter.

DynamicConnectorResource can be used to easily make an appropriate URL available to the client-side code.

Parameters:
request - the request that should be handled
response - the response object to which the response should be written
path - the requested relative path
Returns:
true if the request has been handled, false if no response has been written.
Throws:
java.io.IOException - if there is a problem generating a response.


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