|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xwiki.gwt.user.client.BackForwardCache
public class BackForwardCache
Allows us to preserve the state of the editor against the browser's Back button, the soft page
refresh and the browser crash by using the browser's cache mechanism. Modern browsers cache HTML form fields like
input and textarea as long as they are generated on the server and not on the client using
JavaScript. This class uses the value of such an element to save string properties.
| Constructor Summary | |
|---|---|
BackForwardCache(Element cacheable)
Creates a new cache based on the given HTML element whose value can be cached by the browser. |
|
| Method Summary | |
|---|---|
boolean |
canUpdate()
|
protected java.util.Map<java.lang.String,java.lang.String> |
deserialize(java.lang.String data)
Parses the given string and extracts a map of key-value pairs. |
java.lang.String |
get(java.lang.String key)
Retrieves the value of a cached property specified by the given key. |
java.lang.String |
get(java.lang.String key,
java.lang.String defaultValue)
Retrieves the value of a cached property specified by the given key, falling back on a default value if the key is not found in the cache. |
protected java.util.Map<java.lang.String,java.lang.String> |
getMap()
|
java.lang.String |
put(java.lang.String key,
java.lang.String value)
Adds a new key in the cache or updates the value of an existing key. |
protected java.lang.String |
serialize(java.util.Map<java.lang.String,java.lang.String> map)
Converts the given map of key-value pairs to a string from which it can be recomputed. |
void |
update()
Updates the state of this object. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public BackForwardCache(Element cacheable)
input and textarea.
The browser doesn't cache the HTML elements added dynamically through JavaScript but only the static ones. Moving an element inside the DOM tree prevents the browser from caching its value even if that element was generated on the server.
cacheable - any HTML element whose value can be cached by the browser| Method Detail |
|---|
public java.lang.String get(java.lang.String key)
key - a key in the cache
null if there's no such key in the cache
public java.lang.String get(java.lang.String key,
java.lang.String defaultValue)
key - a key in the cachedefaultValue - the value returned if the specified key is not found in the cache
defaultValue if there's no such key in the cache
public java.lang.String put(java.lang.String key,
java.lang.String value)
key - a key in the cachevalue - the new value for the given key
protected java.util.Map<java.lang.String,java.lang.String> getMap()
Map used to store the cache for quick accesspublic boolean canUpdate()
canUpdate in interface Updatabletrue if this object can be updated at this point, false otherwiseUpdatable.canUpdate()public void update()
update in interface UpdatableUpdatable.update()protected java.util.Map<java.lang.String,java.lang.String> deserialize(java.lang.String data)
data - the string to be deserialized
serialize(Map)protected java.lang.String serialize(java.util.Map<java.lang.String,java.lang.String> map)
map - the map to be serialized
deserialize(String)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||