public class BackForwardCache extends Object implements Updatable
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 and Description |
|---|
BackForwardCache(Element cacheable)
Creates a new cache based on the given HTML element whose value can be cached by the browser.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
canUpdate() |
protected Map<String,String> |
deserialize(String data)
Parses the given string and extracts a map of key-value pairs.
|
String |
get(String key)
Retrieves the value of a cached property specified by the given key.
|
String |
get(String key,
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 Map<String,String> |
getMap() |
String |
put(String key,
String value)
Adds a new key in the cache or updates the value of an existing key.
|
protected String |
serialize(Map<String,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.
|
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 browserpublic String get(String key)
key - a key in the cachenull if there's no such key in the cachepublic String get(String key, String defaultValue)
key - a key in the cachedefaultValue - the value returned if the specified key is not found in the cachedefaultValue if there's no such key in the cachepublic String put(String key, String value)
key - a key in the cachevalue - the new value for the given keyprotected Map<String,String> getMap()
Map used to store the cache for quick accesspublic boolean canUpdate()
public void update()
Updatableprotected Map<String,String> deserialize(String data)
data - the string to be deserializedserialize(Map)protected String serialize(Map<String,String> map)
map - the map to be serializeddeserialize(String)Copyright © 2004–2015 XWiki. All rights reserved.