public class Context extends SimpleBindings
ActionRequest
context.
The request context is mapped to a proxy instance of the bean class on which the action is
being performed. The proxy instance can be accessed via asType(Class)
method.
Example (Java):
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 instance returned from the context is a detached proxy object and should not be used with JPA/Hibernate session. It's only for convenience to get the context values using the bean methods.
Constructor and Description |
---|
Context(Class<?> beanClass)
Create a new
Context for the given bean class. |
Context(Long id,
Class<?> beanClass)
Create a new
Context for a record by given id. |
Context(Map<String,Object> values,
Class<?> beanClass)
Create a new
Context for the given bean class using the given context values. |
Modifier and Type | Method and Description |
---|---|
void |
addChangeListener(PropertyChangeListener listener) |
<T> T |
asType(Class<T> type)
Convert the context as lazy entity of the given type.
|
boolean |
containsKey(Object key) |
Object |
get(Object key) |
Class<?> |
getContextClass() |
Context |
getParent()
Get parent context.
|
Context |
getParentContext()
Deprecated.
|
Object |
put(String name,
Object value) |
clear, containsValue, entrySet, isEmpty, keySet, putAll, remove, size, values
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
public Context(Map<String,Object> values, Class<?> beanClass)
Context
for the given bean class using the given context values.values
- the context valuesbeanClass
- the context bean classpublic Context(Class<?> beanClass)
Context
for the given bean class.beanClass
- the context bean classpublic void addChangeListener(PropertyChangeListener listener)
public Context getParent()
@Deprecated public Context getParentContext()
getParent()
public Class<?> getContextClass()
public <T> T asType(Class<T> type)
type
- the expected typepublic boolean containsKey(Object key)
containsKey
in interface Map<String,Object>
containsKey
in interface Bindings
containsKey
in class SimpleBindings