com.vaadin.addon.touchkit.extensions
Class OfflineMode

java.lang.Object
  extended by com.vaadin.server.AbstractClientConnector
      extended by com.vaadin.server.AbstractExtension
          extended by com.vaadin.addon.touchkit.extensions.OfflineMode
All Implemented Interfaces:
com.vaadin.event.MethodEventSource, com.vaadin.server.ClientConnector, com.vaadin.server.Extension, com.vaadin.shared.Connector, Serializable

public class OfflineMode
extends com.vaadin.server.AbstractExtension

The OfflineMode extension adds offline support for the application. Settings for offline mode can be accessed through this class and offline mode can be triggered even though the network connection is still online.

Author:
Vaadin Ltd
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.vaadin.server.ClientConnector
com.vaadin.server.ClientConnector.AttachEvent, com.vaadin.server.ClientConnector.AttachListener, com.vaadin.server.ClientConnector.ConnectorErrorEvent, com.vaadin.server.ClientConnector.DetachEvent, com.vaadin.server.ClientConnector.DetachListener
 
Constructor Summary
OfflineMode()
           
 
Method Summary
 void beforeClientResponse(boolean initial)
           
 void extend(com.vaadin.ui.UI ui)
           
 int getOfflineModeTimeout()
          Returns the amount of seconds the client side waits for requests to return a response from the server until it opens the offline mode.
protected  OfflineModeState getState()
           
 void goOffline()
          Instructs the client side to go into offline mode.
 boolean isOfflineModeEnabled()
           
 boolean isPersistentSessionCookie()
          Vaadin uses the servlet's session mechanism to track users.
 void setOfflineModeEnabled(boolean offlineModeEnabled)
          Enable or disable offline mode for the application.
 void setOfflineModeTimeout(int offlineModeTimeout)
          Sets the timeout for how long the client side waits for the server to respond before falling back to offline mode.
 void setPersistentSessionCookie(boolean persistentSessionCookie)
          Vaadin uses the servlet's session mechanism to track users.
 
Methods inherited from class com.vaadin.server.AbstractExtension
extend, getParent, getSupportedParentType, remove, setParent
 
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addMethodInvocationToQueue, attach, createState, detach, encodeState, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getState, getStateType, getUI, handleConnectorRequest, hasListeners, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource
 
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, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, getUI, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
 
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
 

Constructor Detail

OfflineMode

public OfflineMode()
Method Detail

getState

protected OfflineModeState getState()
Overrides:
getState in class com.vaadin.server.AbstractClientConnector

isOfflineModeEnabled

public boolean isOfflineModeEnabled()
Returns:
true if offline mode is enabled for the application.

setOfflineModeEnabled

public void setOfflineModeEnabled(boolean offlineModeEnabled)
Enable or disable offline mode for the application.

Parameters:
offlineModeEnabled - true to enable, false to disable.

getOfflineModeTimeout

public int getOfflineModeTimeout()
Returns the amount of seconds the client side waits for requests to return a response from the server until it opens the offline mode. A value of -1 means that offline mode is completely disabled on slow connections.


setOfflineModeTimeout

public void setOfflineModeTimeout(int offlineModeTimeout)
Sets the timeout for how long the client side waits for the server to respond before falling back to offline mode. If the value is set to -1, the client side waits forever.

Parameters:
offlineModeTimeout - timeout in seconds, -1 to disable the timeout.

isPersistentSessionCookie

public boolean isPersistentSessionCookie()
Vaadin uses the servlet's session mechanism to track users. With its default settings, all sessions will be discarded when the browser application closes. For mobile web applications (such as web apps that are added to the home screen in iOS) this might not be the desired solution.

The persistent session cookie is on by default if the UI uses the PreserveOnRefresh annotation.

Returns:
true if the session cookie will be made persistent when closing the browser application

setPersistentSessionCookie

public void setPersistentSessionCookie(boolean persistentSessionCookie)
Vaadin uses the servlet's session mechanism to track users. With its default settings, all sessions will be discarded when the browser application closes. For mobile web applications (such as web apps that are added to the home screen in iOS) this might not be the desired solution.

This method makes the session cookie persistent. A returning user can then be shown his/her previous UI state.

The persistent session cookie is on by default if the UI uses the PreserveOnRefresh annotation. It is suggested to be used with TouchKit applications that might be used as home screen apps.

Note that the normal session lifetime is still respected although persistent cookies are in use.

Parameters:
persistentSessionCookie - true if persistent session cookies should be used

beforeClientResponse

public void beforeClientResponse(boolean initial)
Specified by:
beforeClientResponse in interface com.vaadin.server.ClientConnector
Overrides:
beforeClientResponse in class com.vaadin.server.AbstractClientConnector

goOffline

public void goOffline()
Instructs the client side to go into offline mode. This can be used e.g. if the user knows he is about to lose his network connection or for testing purposes.


extend

public void extend(com.vaadin.ui.UI ui)


Copyright © 2014 Vaadin Ltd. All rights reserved.