|
||||||||||
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.addon.touchkit.extensions.LocalStorage
public class LocalStorage
A server side proxy for the browser's HTML5 local storage. Local storage is a persistent string-string map provided by modern browsers. Using this extension, server side code can access that map.
Local storage can be used bit like traditional cookies to store data on the browser, but with LocalStorage one can store much larger data and the stored data is not transferred in each HTTP request. Also if you have hybrid client-server application, you can use this class to easily fetch date stored by your client side module.
For more details about HTML 5 storage see Storage
.
To save a value in browser use put(String, String)
method.
As the values are behind network, retrieving a value must be done using
asynchronous AP. E.g. like this:
LocalStorage.detectValue("myproperty",
new LocalStorageCallback() {
public void onSuccess(String value) {
Notification.show("Value received:" + value);
}
public void onFailure(FailureEvent error) {
Notification.show("Value retrieval failed: " + error.getMessage());
}
});
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 |
Method Summary | |
---|---|
static void |
detectValue(String key,
LocalStorageCallback callback)
Detects the value of the given key in the client side HTML5 storage. |
static LocalStorage |
get()
Returns a local storage proxy bound to the currently active UI (detected via a thread local). |
void |
get(String key,
LocalStorageCallback callback)
Detects the value of the given key in the client side HTML5 storage. |
static LocalStorage |
get(com.vaadin.ui.UI ui)
Returns a local storage proxy bound to the given UI. |
void |
put(String key,
String value)
Stores a given key-value pair in the browser's local storage. |
void |
put(String key,
String value,
LocalStorageCallback callback)
Stores a given key-value pair in the browser's local storage. |
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, beforeClientResponse, createState, detach, encodeState, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getState, 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, beforeClientResponse, 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 |
Method Detail |
---|
public static void detectValue(String key, LocalStorageCallback callback)
This method uses thread local to get the currently active UI.
get(String, LocalStorageCallback)
public static LocalStorage get()
public static LocalStorage get(com.vaadin.ui.UI ui)
ui
- the UI to bind to.
public void get(String key, LocalStorageCallback callback)
callback
- The LocalStorageCallback
called when the value is
available.public void put(String key, String value)
Note that if you wish to be sure that the value is persisted properly,
you can use put(String, String, LocalStorageCallback)
.
key
- The keyvalue
- The value for the keypublic void put(String key, String value, LocalStorageCallback callback)
The callback given as parameter is notified if local storage access succeeded or failed.
key
- The keyvalue
- The value for the keycallback
- A LocalStorageCallback
to notify of success or
failure.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |