public class Context extends HashMap<String,Object>
ActionRequest
context.asType(Class)
method. Context context = request.getContext(); SaleOrderLine soLine = context.asType(SaleOrderLine.class); SaleOrder so = context.getParentContext().asType(SaleOrder.class);Example (Groovy):
def context = request.context def soLine = context as SaleOrderLine def so = context.parentContext as SaleOrderThe bean instanced returned from the context is a detached object (possibly a cglib proxy) and should not be used with JPA/Hibernate session. It's only for convenience to get the context values using the bean methods.
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Modifier and Type | Method and Description |
---|---|
<T> T |
asType(Class<T> type) |
boolean |
containsKey(Object key) |
static Context |
create(Map<String,Object> data,
Class<?> beanClass) |
Object |
get(Object key) |
Class<?> |
getContextClass() |
Context |
getParentContext() |
void |
update(Map<String,Object> values)
Update the context object with the given values.
Use this method instead of HashMap.putAll(Map) to propagate the values
to the underlying context object. |
void |
update(String key,
Object value)
Update the context with the specified key and value.
Use this method instead of HashMap.put(K, V) to propagate the
value to the underlying context object. |
clear, clone, compute, computeIfAbsent, computeIfPresent, containsValue, entrySet, forEach, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
equals, hashCode, toString
public <T> T asType(Class<T> type)
public Class<?> getContextClass()
public Context getParentContext()
public boolean containsKey(Object key)
containsKey
in interface Map<String,Object>
containsKey
in class HashMap<String,Object>
public void update(String key, Object value)
HashMap.put(K, V)
to propagate the
value to the underlying context object.key
- key with with the context should be updatedvalue
- value to be associated to the given keypublic void update(Map<String,Object> values)
HashMap.putAll(Map)
to propagate the values
to the underlying context object.values
- mappings to be updated